Skip to content

Fix inaccurate exception message in TaskExecutorJobLauncher - #5287

Open
kojw1017 wants to merge 2 commits into
spring-projects:mainfrom
kojw1017:GH-5280
Open

Fix inaccurate exception message in TaskExecutorJobLauncher#5287
kojw1017 wants to merge 2 commits into
spring-projects:mainfrom
kojw1017:GH-5280

Conversation

@kojw1017

Copy link
Copy Markdown

The JobExecutionAlreadyRunningException thrown by TaskExecutorJobLauncher currently includes the JobInstance details instead of the running JobExecution details.

This commit updates the exception to pass the running JobExecution.

Resolves #5280

Thank you for taking time to contribute this pull request!
You might have already read the contributor guide, but as a reminder, please make sure to:

  • Rebase your changes on the latest main branch and squash your commits
  • Add/Update unit tests as needed
  • Run a build and make sure all tests pass prior to submission
  • Sign-off commits according to the Developer Certificate of Origin

For more details, please check the contributor guide.
Thank you upfront!

The JobExecutionAlreadyRunningException thrown by TaskExecutorJobLauncher
currently includes the JobInstance details instead of the running
JobExecution details.

This commit updates the exception to pass the running JobExecution.

Resolves spring-projects#5280

Signed-off-by: kojw1017 <kojw1017@naver.com>
Pin down that the message reports the running JobExecution instead of
the JobInstance.

Signed-off-by: kojw1017 <kojw1017@naver.com>
@kojw1017

Copy link
Copy Markdown
Author

I've pushed a unit test covering this change, since CONTRIBUTING.md asks for JUnit coverage on behavior changes and the original commit had none. TaskExecutorJobLauncherTests didn't exist yet, so it's a new file following the style of the neighbouring CommandLineJobOperatorTests. Reverting the one-line fix makes it fail, so it does pin the behaviour rather than just passing.

Two things that may be worth knowing while reviewing:

  • Although TaskExecutorJobLauncher is deprecated for removal, TaskExecutorJobOperator inherits createJobExecution() through SimpleJobOperator and the method is private, so this fix also corrects the message produced by the currently recommended API. I verified that by driving the same scenario through TaskExecutorJobOperator.start().
  • Line 175 of the same class already passes lastJobExecution, so this brings line 137 in line with the existing form in the file.

The branch is based on the original point rather than rebased, since the PR still reports as mergeable — happy to rebase if you'd prefer. Also glad to open the same change against 6.0.x if the 6.0.6 milestone needs it; just let me know which you'd rather have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inaccurate exception message when attempting to start a running job

1 participant