-
Notifications
You must be signed in to change notification settings - Fork 7.4k
fix: ensuring exit codes are handled consistently #38661
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
Conversation
2347344
to
2b85351
Compare
closes: keycloak#38161 Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
We were making the test launch mode pull double duty. It was both causing an early exit, and preventing System.exit calls. Rather than removing the launch mode from the raw dist, I'm using it only for the early exit. Now we attempt to detect what type of launch were using by the classloader and adjust our exit handling accordingly. @pedroigor does this work for you / embedded usage? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
I tested the embedded server and it seems fine – even better than before as it nows properly exits the process on error instead of just hanging.
int exitCode = ApplicationLifecycleManager.getExitCode(); | ||
|
||
if (isTestLaunchMode() || isNonServerMode()) { | ||
// in test mode we exit immediately | ||
// we should be managing this behavior more dynamically depending on the tests requirements (short/long lived) | ||
Quarkus.asyncExit(exitCode); | ||
Quarkus.asyncExit(ApplicationLifecycleManager.getExitCode()); | ||
} else { | ||
Quarkus.waitForExit(); | ||
} | ||
|
||
return exitCode; | ||
return ApplicationLifecycleManager.getExitCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jus out of curiosity, why is this change needed? Why can't we store the exit code in a var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a potential bug, we don't want to store it because it could change while the waiting for exit.
closes: #38161