spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

Errors are not propagated from job execution [BATCH-2800]

Open spring-projects-issues opened this issue 6 years ago • 0 comments

Paolo opened BATCH-2800 and commented

The piece of code below in the AbstractJob class is catching Throwable, thus preventing the JVM to crash on any Error like it should. Is there a good reason for this ? If so, shouldn't this be documented somewhere ? It can be really surprising and upsetting when you find this out in a production environment. See details in the linked StackOverflow thread.

@Override
public final void execute(JobExecution execution) {
    [...]
    try {
            [...]
    } catch (Throwable t) {
            logger.error("Encountered fatal error executing job", t);
            execution.setExitStatus(getDefaultExitStatusForFailure(t, execution));
            execution.setStatus(BatchStatus.FAILED);
            execution.addFailureException(t);
    }

Affects: 4.1.1

Reference URL: https://stackoverflow.com/questions/54811702/spring-batch-doesnt-propagate-errors

spring-projects-issues avatar Mar 21 '19 09:03 spring-projects-issues