diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBean.java index 782bf6460..d0e3db9d7 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBean.java @@ -262,8 +262,9 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean itemReader = getItemReader(); + for (ItemStream stream : streams) { + if (stream == itemReader) { streamIsReader = true; composite.register(stream); } @@ -279,7 +280,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean reader = new ItemStreamReader() { + public void close() throws ItemStreamException { + } + + public void open(ExecutionContext executionContext) throws ItemStreamException { + } + + public void update(ExecutionContext executionContext) throws ItemStreamException { + } + + public String read() throws Exception, UnexpectedInputException, ParseException { + return null; + } + }; + + ItemStreamReader stream = new ItemStreamReader() { + public void close() throws ItemStreamException { + closed = true; + } + + public void open(ExecutionContext executionContext) throws ItemStreamException { + opened = true; + } + + public void update(ExecutionContext executionContext) throws ItemStreamException { + } + + public String read() throws Exception, UnexpectedInputException, ParseException { + return null; + } + }; + + factory.setItemReader(reader); + factory.setStreams(new ItemStream[] {stream, reader}); + + Step step = (Step) factory.getObject(); + + step.execute(stepExecution); + + assertTrue(opened); + assertTrue(closed); + assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); + } + private static class SkipProcessorStub implements ItemProcessor { private final Collection failures;