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

Improve documentation for exit code generation #5038

Closed
prasenjit-net opened this issue Jan 27, 2016 · 3 comments
Closed

Improve documentation for exit code generation #5038

prasenjit-net opened this issue Jan 27, 2016 · 3 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@prasenjit-net
Copy link

I was using the exit code generator feature and as per the document

In addition, beans may implement the org.springframework.boot.ExitCodeGenerator interface if they wish to return a specific exit code when the application ends.

Does this bean gets called whenever a proper shut down happen, or it require a call to SpringApplication.exit static method?

For me first option is not happening on a spring boot console application i.e. no web dependency. But when I call the SpringApplication.exit static method ExitCodeGenerator.getExitCode is called but still returns exit code 0 and also it forces the tests to fail with a message that

Ensure that the context has not been closed programmatically.

example can be found here boot-exitcode

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 27, 2016
@wilkinsona
Copy link
Member

Does this bean gets called whenever a proper shut down happen, or it require a call to SpringApplication.exit static method?

It's required to call the exit method.

But when I call the SpringApplication.exit static method ExitCodeGenerator.getExitCode is called but still returns exit code 0 and also it forces the tests to fail

You're not doing anything with the application's exit code, i.e. you haven't passed it into a call to System.exit(), so the JVM's default exit code is being produced. As the JVM has exited cleanly, it's zero.

Take a look at SampleBatchApplication to see how we expect the application's exit code to be used:

System.exit(SpringApplication
        .exit(SpringApplication.run(SampleBatchApplication.class, args)));

@wilkinsona wilkinsona removed the status: waiting-for-triage An issue we've not yet triaged label Feb 2, 2016
@prasenjit-net
Copy link
Author

OK my bad I should have posted it to SW. But isn't it good to have it documented as well.

@wilkinsona wilkinsona changed the title Spring Boot Exit Code Generation Improve documentation for exit code generation Feb 3, 2016
@wilkinsona wilkinsona reopened this Feb 3, 2016
@wilkinsona wilkinsona added type: documentation A documentation update for: team-attention An issue we'd like other members of the team to review labels Feb 3, 2016
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Feb 3, 2016
@snicoll
Copy link
Member

snicoll commented Jul 13, 2017

Closing in favour of PR #9740

@snicoll snicoll closed this as completed Jul 13, 2017
@snicoll snicoll added status: duplicate A duplicate of another issue and removed type: documentation A documentation update labels Jul 13, 2017
@philwebb philwebb added status: superseded An issue that has been superseded by another and removed status: duplicate A duplicate of another issue labels Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants