Skip to content

Commit

Permalink
Merge pull request quarkusio#42208 from Sanne/ShutdownRace
Browse files Browse the repository at this point in the history
Avoid a possible NPE during application stop
  • Loading branch information
aloubyansky authored Jul 29, 2024
2 parents b31c632 + 0e74800 commit a02d772
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,15 @@ public void run() {
} finally {
stateLock.unlock();
}
if (currentApplication.isStarted()) {
//take a reliable reference before changing the application state:
final Application app = currentApplication;
if (app.isStarted()) {
// On CLI apps, SIGINT won't call io.quarkus.runtime.Application#stop(),
// making the awaitShutdown() below block the application termination process
// It should be a noop if called twice anyway
currentApplication.stop();
app.stop();
}
currentApplication.awaitShutdown();
app.awaitShutdown();
currentApplication = null;
System.out.flush();
System.err.flush();
Expand Down

0 comments on commit a02d772

Please sign in to comment.