spring-projects / spring-projects/spring-batch
Exceptions in close do not fail job [BATCH-2363]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 2.5k
- Avg merge
- 6d 53m
- Merged PRs (30d)
- 3
Description
Brian Rogers opened BATCH-2363 and commented
If an exception is called in a chunk write close step the job proceeds as normal and the exception escapes. I have an unacceptable work around of catching exceptions and setting the exit status to FAILED which at least causes the job not to proceed the next step. What I lose however is the ability to fail the step and to capture the exception trace in exit_message.
Based on looking at the code (AbstractStep.java) it's clear what's happening. The step is marked as complete, control proceeds to the finally block, and ultimately the close is called. The only thing that is done with exceptions in close is to add them to the stepExecution.
I'm not sure where control passes after that and what causes the execution to be persisted but something would have to be interjected around this point.
Affects: 3.0.1, 3.0.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java, where the issue identifies the close handling. Trace how close exceptions are added to the step execution and how execution persistence proceeds. Done means a close exception fails the step and job, prevents the next step from proceeding, and preserves the exception trace in exit_message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100