Skip to content

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

Open
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions