GH-5439 Surface the real reason a job execution cannot be restarted#5440
Open
kyungrae wants to merge 1 commit into
Open
GH-5439 Surface the real reason a job execution cannot be restarted#5440kyungrae wants to merge 1 commit into
kyungrae wants to merge 1 commit into
Conversation
f443523 to
1980878
Compare
SimpleJobOperator.restart(JobExecution) caught every exception thrown by run(...) and rewrapped it into a JobRestartException with a hardcoded "job execution already running" message. This masked the actual reason reported by the launcher — most notably "Cannot restart job from UNKNOWN status" — sending users down the wrong debugging path. Catch only JobExecutionAlreadyRunningException for the "already running" message, wrap JobInstanceAlreadyCompleteException and InvalidJobParametersException with their own messages, and let JobRestartException propagate unchanged so its specific message survives. Resolves spring-projects#5439 Signed-off-by: Kyungrae Kim <rlarudfo93@gmail.com>
1980878 to
102617d
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.
Resolves #5439
Problem
SimpleJobOperator.restart(JobExecution)wraps every exception thrown byrun(...)into aJobRestartExceptionwith a hardcoded"job execution already running"message:The launcher (TaskExecutorJobLauncher.createJobExecution) already throws accurate, specific exceptions for the various non-restartable conditions. For example, when the last execution (or one of its step executions) ended in UNKNOWN status:
Because the operator catches the broad Exception and rebuilds the message, that accurate reason is demoted to the cause and the top-level message wrongly states the job is "already running" — even though it is not (it is UNKNOWN, already complete, or had invalid parameters). Users and logs are then sent down the wrong debugging path.
Note: although SimpleJobOperator is deprecated in favour of TaskExecutorJobOperator, the latter inherits this method via super.restart(...), so the active operator is affected.
Change
Replace the broad catch (Exception e) with per-type handling: