{"record":{"id":"a3137b1e1cc31ce4","repo":"quarkusio/quarkus","slug":"runtime-config-has-already-been-set","errorCode":null,"errorMessage":"runtime config has already been set","messagePattern":"runtime config has already been set","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/Deployment.java","lineNumber":209,"sourceCode":"    public ThreadSetupAction getThreadSetupAction() {\n        return threadSetupAction;\n    }\n\n    public RequestContextFactory getRequestContextFactory() {\n        return requestContextFactory;\n    }\n\n    public List<GenericRuntimeConfigurableServerRestHandler<?>> getRuntimeConfigurableServerRestHandlers() {\n        return runtimeConfigurableServerRestHandlers;\n    }\n\n    public RuntimeConfiguration getRuntimeConfiguration() {\n        return runtimeConfiguration;\n    }\n\n    public Deployment setRuntimeConfiguration(RuntimeConfiguration runtimeConfiguration) {\n        if (this.runtimeConfiguration != null) {\n            throw new IllegalStateException(\"runtime config has already been set\");\n        }\n        this.runtimeConfiguration = runtimeConfiguration;\n        return this;\n    }\n\n    public Map<String, List<String>> getDisabledEndpoints() {\n        return disabledEndpoints;\n    }\n}\n","sourceCodeStart":191,"sourceCodeEnd":219,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/Deployment.java#L191-L219","documentation":"Deployment.setRuntimeConfiguration is idempotent-by-first-write: once a RuntimeConfiguration has been installed on a Deployment, calling setRuntimeConfiguration again throws this IllegalStateException. The deployment refuses to swap runtime configuration after it has been set, to keep configuration consistent for the live application.","triggerScenarios":"Calling createApplication-style bootstrapping code that invokes deployment.setRuntimeConfiguration(cfg) more than once on the same Deployment instance — e.g. a custom bootstrap, dev-mode restart path, or test harness that re-sets config.","commonSituations":"Custom embedding of RESTEasy Reactive (not via Quarkus) where the setup code is accidentally executed twice; test frameworks building the Deployment in @BeforeEach without recreating the Deployment object; double initialization after a runtime reload.","solutions":["Call setRuntimeConfiguration exactly once per Deployment instance; create a new Deployment if configuration must change.","Guard your bootstrap code with an 'initialized' flag or check deployment.getRuntimeConfiguration() != null before setting.","In tests, rebuild the Deployment object for each test rather than reusing and reconfiguring a shared instance."],"exampleFix":"// before\ndeployment.setRuntimeConfiguration(cfg); // called twice in restart path\n// after\nif (deployment.getRuntimeConfiguration() == null) {\n    deployment.setRuntimeConfiguration(cfg);\n}","handlingStrategy":"try-catch","validationCode":"if (deployment.getRuntimeConfiguration() != null) {\n    // skip re-setting, or replace the whole Deployment\n} else {\n    deployment.setRuntimeConfiguration(runtimeConfig);\n}","typeGuard":null,"tryCatchPattern":"try {\n    deployment.setRuntimeConfiguration(cfg);\n} catch (IllegalStateException e) {\n    if (\"runtime config has already been set\".equals(e.getMessage())) {\n        log.warn(\"Runtime configuration already set; reusing existing configuration\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Initialize the Deployment in a single well-defined bootstrap method.","Make bootstrap idempotent with an initialization guard flag.","In tests, construct a new Deployment per test lifecycle phase.","Audit dev-mode/restart code paths for repeated calls into setup methods."],"tags":["quarkus","resteasy-reactive","lifecycle","configuration","double-initialization"],"backgroundTag":"double-initialization","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}