RESOLVED - issue BATCH-532: StepExecutionListener can influence exit status but not status of step execution

removed the try/catch block around listener.afterStep()
updated javadoc for StepExecutionListener#afterStep(..)
This commit is contained in:
robokaso
2008-04-01 11:40:59 +00:00
parent 7746cfc304
commit bff748f576
3 changed files with 34 additions and 6 deletions

View File

@@ -168,6 +168,36 @@ public class TaskletStepTests extends TestCase {
assertEquals("Job interrupted while executing tasklet", expected.getMessage());
}
}
/**
* Exception in {@link StepExecutionListener#afterStep(StepExecution)}
* causes step to fail.
* @throws JobInterruptedException
*/
public void testStepFailureInAfterStepCallback() throws JobInterruptedException {
TaskletStep step = new TaskletStep(new Tasklet() {
public ExitStatus execute() throws Exception {
return ExitStatus.FINISHED;
}
}, new JobRepositorySupport());
StepExecutionListener listener = new StepExecutionListenerSupport() {
public ExitStatus afterStep(StepExecution stepExecution) {
throw new RuntimeException("exception thrown in afterStep to signal failure");
}
};
step.setStepListeners(new StepExecutionListener[] { listener });
try {
step.execute(stepExecution);
fail();
}
catch (RuntimeException expected) {
assertEquals("exception thrown in afterStep to signal failure", expected.getMessage());
}
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
}
private class StubTasklet extends StepExecutionListenerSupport implements Tasklet {