{"record":{"id":"5ac031c21155d2b3","repo":"quarkusio/quarkus","slug":"cannot-reset-a-started-application","errorCode":null,"errorMessage":"Cannot reset a started application","messagePattern":"Cannot reset a started application","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/devmode-spi/src/main/java/io/quarkus/dev/appstate/ApplicationStateNotification.java","lineNumber":20,"sourceCode":"\n/**\n * A class that allows for access to the application state, even from outside the runtime class loader.\n *\n * This should generally only be used by dev mode internals that need information about the current\n * application state.\n *\n * This class makes no attempt to verify that an application is starting/stopping when the\n * wait methods are called, this should only be called by a client that is controlling the Quarkus\n * lifecycle, and so knows what the current lifecycle state is.\n */\npublic class ApplicationStateNotification {\n\n    private static State state = State.INITIAL;\n    private static Throwable startupProblem;\n\n    public static synchronized void reset() {\n        if (state == State.STARTED) {\n            throw new IllegalStateException(\"Cannot reset a started application\");\n        }\n        state = State.INITIAL;\n        startupProblem = null;\n    }\n\n    public static synchronized void notifyStartupComplete() {\n        state = State.STARTED;\n        ApplicationStateNotification.class.notifyAll();\n    }\n\n    public static synchronized void notifyApplicationStopped() {\n        state = State.STOPPED;\n        ApplicationStateNotification.class.notifyAll();\n    }\n\n    /**\n     * Notify of startup failure.\n     *","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/devmode-spi/src/main/java/io/quarkus/dev/appstate/ApplicationStateNotification.java#L2-L38","documentation":"ApplicationStateNotification tracks global dev-mode application state. reset() restores the INITIAL state between (re)deployments, but resetting an application that is currently STARTED would corrupt lifecycle tracking, so it is rejected with this IllegalStateException.","triggerScenarios":"Calling ApplicationStateNotification.reset() while state == State.STARTED — e.g. a dev tool attempting to reset state without first stopping the running application, or a lifecycle race where restart logic runs before shutdown notification completes.","commonSituations":"Custom dev-mode tooling resetting state between hot reloads while the old instance still runs; test harnesses reusing state helpers across started applications.","solutions":["Stop/shut down the running application before calling reset()","Use ApplicationStateNotification.waitForApplicationState(...) to confirm the app left STARTED state before resetting","Restructure restart logic to go through the framework's redeploy path instead of manual reset","Guard reset() behind a state check if you control the caller"],"exampleFix":"// before\nApplicationStateNotification.reset(); // throws if STARTED\n// after\nApplicationStateNotification.waitForApplicationState(Duration.ofSeconds(10), State.STOPPED);\nApplicationStateNotification.reset();","handlingStrategy":"validation","validationCode":"// before reset\nState s = ApplicationStateNotification.waitForApplicationState(Duration.ZERO, State.STOPPED, State.INITIAL);\nif (s == State.STARTED) { /* stop application first */ }","typeGuard":null,"tryCatchPattern":"try { ApplicationStateNotification.reset(); } catch (IllegalStateException e) { if (e.getMessage().contains(\"Cannot reset a started application\")) { /* shut down app, then reset */ } else { throw e; } }","preventionTips":["Always stop the application before resetting state","Use waitForApplicationState to synchronize on state transitions","Prefer the framework redeploy path over manual reset"],"tags":["quarkus","dev-mode","lifecycle","state"],"backgroundTag":"invalid-application-state","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"}