{"record":{"id":"4a2c825e098f52a1","repo":"quarkusio/quarkus","slug":"the-application-is-stopping","errorCode":null,"errorMessage":"The application is stopping","messagePattern":"The application is stopping","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/Application.java","lineNumber":104,"sourceCode":"        stateLock.lock();\n        try {\n            loop: for (;;)\n                switch (state) {\n                    case ST_INITIAL:\n                        break loop; // normal startup\n                    case ST_STARTING: {\n                        try {\n                            stateCond.await();\n                        } catch (InterruptedException e) {\n                            Thread.currentThread().interrupt();\n                            throw interruptedOnAwaitStart();\n                        }\n                        break;\n                    }\n                    case ST_STARTED:\n                        return; // all good\n                    default: {\n                        throw new IllegalStateException(\"The application is stopping\");\n                    }\n                }\n            state = ST_STARTING;\n        } finally {\n            stateLock.unlock();\n        }\n        try {\n            doStart(args);\n        } catch (Throwable t) {\n            stateLock.lock();\n            final ConfigProviderResolver cpr = ConfigProviderResolver.instance();\n            try {\n                cpr.releaseConfig(cpr.getConfig());\n            } catch (IllegalStateException ignored) {\n                // just means no config was installed, which is fine\n            }\n            try {\n                state = ST_STOPPED;","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/Application.java#L86-L122","documentation":"Application.start() synchronizes on a state lock and only proceeds when the application state allows starting; ST_STARTED returns immediately, but any other non-starting state (i.e. the application is shutting down or stopped) throws this IllegalStateException. It protects against starting work on an application instance whose lifecycle is winding down, typically during shutdown races.","triggerScenarios":"Calling start() (directly or via run/QuarkusHttpFunction/QuarkusBackgroundFunction/QuarkusCloudEventsFunction) while another thread has moved the instance into the stopping/stopped state — e.g. a shutdown hook fired concurrently with startup.","commonSituations":"Container SIGTERM arriving while the app is still booting; tests that stop the app in a background thread and then try to start it again; framework callbacks racing with shutdown.","solutions":["Inspect why the application was stopping: check logs for a concurrent shutdown (shutdown hook, SIGTERM, another stop() call).","Do not reuse a stopped Application instance; create a new instance and start that.","Serialize lifecycle: ensure shutdown hooks and manual stop() are not invoked concurrently with start() in your code/tests.","If triggered by the platform (container restart), treat it as expected behavior and let the new process boot a fresh instance."],"exampleFix":"// before: reusing the stopped instance\napp.stop();\napp.start(); // IllegalStateException: The application is stopping\n// after: new instance\napp = new Application();\nApplicationLifecycleManager.run(app, null, null, LaunchMode.NORMAL);","handlingStrategy":"try-catch","validationCode":"// start only if not already shutting down\nif (lifecycleManager.isShutdownRequested()) {\n    throw new IllegalStateException(\"Refusing to start during shutdown\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    app.start();\n} catch (IllegalStateException e) {\n    if (\"The application is stopping\".equals(e.getMessage())) {\n        log.warn(\"Start raced with shutdown; booting a fresh instance\");\n        app = createAndStartNewApplication();\n    } else throw e;\n}","preventionTips":["Never call start() from shutdown hooks or shutdown paths.","Coordinate lifecycle calls with a single owner thread or executor.","In containers, let the platform restart the process rather than restarting a stopped instance.","In tests, use framework-managed lifecycle (@QuarkusTest) instead of manual start/stop."],"tags":["quarkus","lifecycle","concurrency","shutdown"],"backgroundTag":"application-stopping","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}