Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobLauncherApplicationRunner returns a success exit code even when no jobs have been run #36060

Closed

Conversation

itsAkshayDubey
Copy link
Contributor

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

.withPropertyValues("spring.batch.job.names:discreteLocalJob,nonConfiguredJob")
.run((context) -> {
assertThat(context).hasSingleBean(JobLauncher.class);
assertThrows(NoSuchJobException.class,()->{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Spring Boot style rules don't allow JUnit assertThrows(). Please use the AssertJ assertThatIllegalArgumentException() or assertThatExceptionOfType() instead.

@scottfrederick
Copy link
Contributor

@itsAkshayDubey Thanks for the PR. As also suggested in the issue comments, it would be better to fail early if any job names are unknown instead of potentially processing some jobs and then failing. Starting in Spring Boot 3.0, some validation is done in a @PostConstruct method of JobLauncherApplicationRunner. Can you make changes to this PR so that this validation of job names is also done in a @PostConstruct method? That would also make it easier to forward-merge the changes to later release branches.

@itsAkshayDubey
Copy link
Contributor Author

Hi @scottfrederick ,

Added suggested changes, kindly have a look.

Thanks,
Akshay

@snicoll snicoll self-assigned this Jul 24, 2023
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 24, 2023
@snicoll snicoll added this to the 2.7.15 milestone Jul 24, 2023
snicoll pushed a commit that referenced this pull request Jul 24, 2023
snicoll added a commit that referenced this pull request Jul 24, 2023
@snicoll snicoll closed this in 45f685f Jul 24, 2023
@snicoll
Copy link
Member

snicoll commented Jul 24, 2023

@itsAkshayDubey thank you for making your first contribution to Spring Boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants