0

An exception in an ItemWriter#close method is not causing the exit status to be marked as FAILED. Can you confirm that is the expected behavior ?

According to my understanding, when ItemWriter#close method is called, the items must have been processed successfully.

We encountered no errors during the phase of reader, processor or writer.

As as result, the exit status is marked as COMPLETED.

In other words, ItemWriter#close method is only useful for clean up of resources and does not impact the results of the step.

Do you agree with my explanation ? Can you confirm ?

Thank you in advance for your answers.

buck
  • 31
  • 3
  • Please be more specific about the issue? Which ItemProcessor implementation are you using? Source code? Which exception are using for the simulation? – Mar-Z Mar 19 '23 at 11:22
  • I use the method close of this class, and an ioexception is launched : https://github.com/spring-projects/spring-batch/blob/main/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractFileItemWriter.java – buck Mar 19 '23 at 11:35
  • What exception exactly? Please add stack trace to the question. – Mar-Z Mar 19 '23 at 14:50
  • Thanks, i found explanation in this article : https://github.com/spring-projects/spring-batch/issues/1726 – buck Mar 19 '23 at 15:41

1 Answers1

0

There is no ItemWriter#close, it is rather ItemStream#close.

ItemStream#close is designed to clean up resources that were used in the step, and nothing more. If an exception is thrown in that method, all the relevant business processing should have been already done at this point so it should not cause a failure of the step.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50