diff --git a/core/runtime/src/main/java/io/quarkus/runtime/ApplicationLifecycleManager.java b/core/runtime/src/main/java/io/quarkus/runtime/ApplicationLifecycleManager.java index 48c18f868b7b2..d16e5ff7e94af 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/ApplicationLifecycleManager.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/ApplicationLifecycleManager.java @@ -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();