JobLauncherApplicationRunner returns a success exit code even when no jobs have been run. fix: Rethrowing JobExecutionException when NoSuchJobException is caught. Closes: #35940

Comment From: pivotal-cla

@itsAkshayDubey Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@itsAkshayDubey Thank you for signing the Contributor License Agreement!

Comment From: itsAkshayDubey

Thanks for the PR, @itsAkshayDubey. I've left a comment for your consideration. It would also be good to update JobLauncherApplicationRunnerTests to add a test that asserts that an exception is thrown when an attempt is made to execute a job that doesn't exist.

Added in this commit

Comment From: itsAkshayDubey

Hello @wilkinsona @scottfrederick ,

Pl. have a look.

Thanks, Akshay

Comment From: scottfrederick

Unfortunately, the suggestion of just removing the try/catch isn't the right fix for this issue.

When this issue is fixed, this test should continue to pass as it is currently written, since the job named discreteRegisteredJob is a valid local job with this test setup. Removing the try/catch results in the exception being thrown from executeRegisteredJobs after the local job has been run successfully in executeLocalJobs.

What we need is a way to detect that a given job in spring.batch.job.names was not run by either executeLocalJobs or executeRegisteredJobs. A new test that sets the spring.batch.job.names property to include at least one job name that has not been configured will be required to verify the desired behavior.

I'm going to close this PR and re-open the issue so we can think more about the solution. @itsAkshayDubey If you'd like to take another look and suggest a fix that meets the requirements in a new PR, let us know in the issue and we can assign it to you.