@Override
    public void run() {
        try {
            backgroundJobServer.getJobSteward().notifyThreadOccupied();
            MDCMapper.loadMDCContextFromJob(job);
            performJob();
        } catch (Exception e) {
            if (isJobDeletedWhileProcessing(e)) {
                // nothing to do anymore as Job is deleted
                return;
            } else if (isJobServerStopped(e)) {
                updateJobStateToFailedAndRunJobFilters("Job processing was stopped as background job server has stopped", e);
                Thread.currentThread().interrupt();
            } else if (isJobNotFoundException(e)) {
                updateJobStateToFailedAndRunJobFilters("Job method not found", e);
            } else {
                updateJobStateToFailedAndRunJobFilters("An exception occurred during the performance of the job", e);
            }
        } finally {
            backgroundJobServer.getJobSteward().notifyThreadIdle();
            MDC.clear();
        }
    }
@Test
    @DisplayName("any exception other than InvocationTargetException stays unwrapped")
    void anyExceptionOtherThanInvocationTargetExceptionIsNotUnwrapped() throws Exception {
        var job = anEnqueuedJob().build();
        var runner = mock(BackgroundJobRunner.class);
        doThrow(new RuntimeException("test error")).when(runner).run(job);
        when(backgroundJobServer.getBackgroundJobRunner(job)).thenReturn(runner);

        var backgroundJobPerformer = new BackgroundJobPerformer(backgroundJobServer, job);
        backgroundJobPerformer.run();

        var lastFailure = job.getLastJobStateOfType(FailedState.class);
        assertThat(lastFailure.isPresent()).isTrue();
        assertThat(lastFailure.get().getExceptionMessage()).isEqualTo("test error");
        assertThat(lastFailure.get().getException()).isInstanceOf(RuntimeException.class);
        assertThat(lastFailure.get().getException().getMessage()).isEqualTo("test error");
    }