diff --git a/src/site/docbook/reference/common-patterns.xml b/src/site/docbook/reference/common-patterns.xml index 85cbf234a..6478bad18 100644 --- a/src/site/docbook/reference/common-patterns.xml +++ b/src/site/docbook/reference/common-patterns.xml @@ -493,12 +493,11 @@ public class NoWorkFoundStepExecutionListener extends StepExecutionListenerSupport { - public ExitStatus afterStep(StepExecution stepExecution) { - if (stepExecution.getReadCount() == 0) { - throw new NoWorkFoundException("Step has not processed any items"); - } - return stepExecution.getExitStatus(); + public ExitStatus afterStep(StepExecution stepExecution) { + if (stepExecution.getReadCount() == 0) { + return ExitStatus.FAILED; } + return null; } @@ -506,7 +505,9 @@ The above StepExecutionListener inspects the readCount property of the StepExecution during the 'afterStep' phase to determine if no items were read. If that is the case, - an exception is thrown, causing the Step to - fail. + an exit code of FAILED is returned, indicating that the + Step should fail. Otherwise, null is returned, + which will not affect the status of the + Step.