diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoItemsProcessedDetector.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundListener.java similarity index 78% rename from spring-batch-core/src/main/java/org/springframework/batch/core/step/NoItemsProcessedDetector.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundListener.java index 59f6b72c2..d98b59575 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoItemsProcessedDetector.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundListener.java @@ -18,6 +18,7 @@ package org.springframework.batch.core.step; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.listener.StepExecutionListenerSupport; +import org.springframework.batch.item.NoWorkFoundException; import org.springframework.batch.repeat.ExitStatus; /** @@ -25,19 +26,13 @@ import org.springframework.batch.repeat.ExitStatus; * * @author Robert Kasanicky */ -public class NoItemsProcessedDetector extends StepExecutionListenerSupport { +public class NoWorkFoundListener extends StepExecutionListenerSupport { public ExitStatus afterStep(StepExecution stepExecution) { if (stepExecution.getItemCount().intValue() == 0) { - throw new NoItemsProcessedException("Step has not processed any items"); + throw new NoWorkFoundException("Step has not processed any items"); } return stepExecution.getExitStatus(); } - private static class NoItemsProcessedException extends RuntimeException { - public NoItemsProcessedException(String message) { - super(message); - } - } - } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoItemsProcessedDetectorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundListenerTests.java similarity index 86% rename from spring-batch-core/src/test/java/org/springframework/batch/core/step/NoItemsProcessedDetectorTests.java rename to spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundListenerTests.java index a5937540e..be95eb31d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoItemsProcessedDetectorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NoWorkFoundListenerTests.java @@ -20,10 +20,11 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobInstance; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; +import org.springframework.batch.item.NoWorkFoundException; -public class NoItemsProcessedDetectorTests extends TestCase { +public class NoWorkFoundListenerTests extends TestCase { - private NoItemsProcessedDetector tested = new NoItemsProcessedDetector(); + private NoWorkFoundListener tested = new NoWorkFoundListener(); /** * If item count is zero exception is thrown @@ -38,7 +39,7 @@ public class NoItemsProcessedDetectorTests extends TestCase { try { tested.afterStep(stepExecution); fail(); - } catch (RuntimeException e) { + } catch (NoWorkFoundException e) { assertEquals("Step has not processed any items", e.getMessage()); } } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/NoWorkFoundException.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/NoWorkFoundException.java index da49b3e08..9bfc95e6f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/NoWorkFoundException.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/NoWorkFoundException.java @@ -16,7 +16,8 @@ package org.springframework.batch.item; /** - * Exception indicating that an {@link ItemReader} found no work to process while initializing. + * Exception indicating no work was found - e.g. the input is empty or + * more generally no items were processed. * * @author Lucas Ward * @author Ben Hale