Propagate step exit description from FlowJob to JobExecution#5430
Open
seonwooj0810 wants to merge 1 commit into
Open
Propagate step exit description from FlowJob to JobExecution#5430seonwooj0810 wants to merge 1 commit into
seonwooj0810 wants to merge 1 commit into
Conversation
Issue: spring-projectsgh-3740 When a step inside a FlowJob fails, the StepExecution's exit status already contains the failure description (typically the stack trace recorded by AbstractStep). However, JobFlowExecutor.executeStep only returned the exit code, and the final JobFlowExecutor.updateJobExecutionStatus combined the executor's tracked ExitStatus (which had no description) with an ExitStatus built from the FlowExecutionStatus name. As a result the step's exit description was discarded and the JobExecution ended with an empty exit description, in contrast to SimpleJob which assigns stepExecution.getExitStatus() directly. Accumulate the step's exit description into the executor's tracked ExitStatus in executeStep so it survives the final updateJobExecutionStatus call. ExitStatus.addExitDescription already deduplicates equal descriptions and concatenates distinct ones with a semicolon, so multiple step failures along a flow path are preserved without duplication. Signed-off-by: Seonwoo Jung <laborlawseon@kap.kr>
468d5f9 to
c4f740f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3740
Root cause
When a step inside a
FlowJobfails, theStepExecution's exit status already contains the failure description (typically the stack trace appended byAbstractStep.execute()viaExitStatus.addExitDescription(ex)).SimpleJobpropagates that description to theJobExecutiondirectly indoExecute():FlowJobdoes not. Instead, it relies onJobFlowExecutor.updateJobExecutionStatus(FlowExecutionStatus), which only carries the final flow status name:executeSteppreviously returned only the step's exit code and discarded its exit description. The executor's trackedexitStatustherefore stayed atExitStatus.EXECUTING(description"") until it was merged withnew ExitStatus(status.getName())— also without a description. The result: when aFlowJobends inFAILED, the resultingJobExecution.getExitStatus().getExitDescription()is empty, even though the failing step has the exception detail. Tooling and listeners that inspect the job-level exit description (e.g. job-level logging, downstream notification jobs) lose the cause.Change
In
JobFlowExecutor.executeStep, accumulate the just-executed step's exit description into the executor's trackedExitStatusviaExitStatus.addExitDescription. The subsequentupdateJobExecutionStatusthen merges the description through to theJobExecution.ExitStatus.addExitDescriptionalready:thiswhen the new description is blank, so successful steps with empty descriptions cost nothing;;, so multiple failing steps along a flow path are preserved without losing earlier context.This mirrors
SimpleJob's behavior while staying compatible with arbitrary flow shapes — including transitions, decisions, and split flows where multiple step executions may carry descriptions.Test evidence
Added
FlowJobFailureTests#testStepFailureExitDescriptionPropagatedToJobExecution. The test installs a step that setsExitStatus.FAILED.addExitDescription("boom: simulated step failure")and asserts that the resultingJobExecution.getExitStatus().getExitDescription()contains that text.'').All existing tests in
org.springframework.batch.core.job.flow.**andorg.springframework.batch.core.job.**continue to pass:(Skipped tests are pre-existing infrastructure-dependent tests.)
Verification done
gh pr list --search "FlowJob ExitDescription"andgh pr list --search "JobFlowExecutor updateJobExecutionStatus"both empty..javafiles only.main(d8447d8bc) by greppingJobFlowExecutor.updateJobExecutionStatusand inspectingexecuteStep.JobFlowExecutor(fails with empty description) and against the patched version (passes).SimpleJob.doExecute()andJobFlowExecutor.updateJobExecutionStatus()— the description here matches the analysis the issue author already laid out.