diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index 5df121a7b..23a54beda 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -166,11 +166,12 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw throw new UnexpectedJobExecutionException("Failed to initialize the step", e); } exitStatus = doExecute(stepExecution); + + stepExecution.setStatus(BatchStatus.COMPLETED); exitStatus = exitStatus.and(getCompositeListener().afterStep(stepExecution)); try { getJobRepository().saveOrUpdateExecutionContext(stepExecution); - stepExecution.setStatus(BatchStatus.COMPLETED); } catch (Exception e) { commitException = e;