{"record":{"id":"f477efdffe2ee776","repo":"quarkusio/quarkus","slug":"trying-to-invoke-contextpropagation-on-a-partially","errorCode":null,"errorMessage":"Trying to invoke ContextPropagation on a partially-configured ContextManager instance. You should wait until runtime init is done. You can do that by consuming the ContextPropagationBuildItem.","messagePattern":"Trying to invoke ContextPropagation on a partially-configured ContextManager instance\\. You should wait until runtime init is done\\. You can do that by consuming the ContextPropagationBuildItem\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java","lineNumber":115,"sourceCode":"            return null;\n        }\n\n        @Override\n        public <T> T invokeAny(Collection<? extends Callable<T>> tasks)\n                throws InterruptedException, ExecutionException {\n            nope();\n            return null;\n        }\n\n        @Override\n        public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)\n                throws InterruptedException, ExecutionException, TimeoutException {\n            nope();\n            return null;\n        }\n\n        private void nope() {\n            throw new RuntimeException(\n                    \"Trying to invoke ContextPropagation on a partially-configured ContextManager instance. You should wait until runtime init is done. You can do that by consuming the ContextPropagationBuildItem.\");\n        }\n    };\n    private static SmallRyeContextManager.Builder builder;\n\n    public void configureStaticInit(List<ThreadContextProvider> discoveredProviders,\n            List<ContextManagerExtension> discoveredExtensions) {\n        // build the manager at static init time\n        // in the live-reload mode, the provider instance may be already set in the previous start\n        if (ContextManagerProvider.INSTANCE.get() == null) {\n            ContextManagerProvider contextManagerProvider = new QuarkusContextManagerProvider();\n            ContextManagerProvider.register(contextManagerProvider);\n        }\n\n        // do what config we can here, but we need the runtime executor service to finish\n        builder = (SmallRyeContextManager.Builder) ContextManagerProvider.instance()\n                .getContextManagerBuilder();\n        builder.withThreadContextProviders(discoveredProviders.toArray(new ThreadContextProvider[0]));","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java#L97-L133","documentation":"Before runtime init completes, the context propagation extension substitutes a placeholder executor whose every method calls nope(), which throws a RuntimeException telling you the ContextManager is only partially configured and to wait for runtime init — e.g. by consuming the ContextPropagationBuildItem in a build step.","triggerScenarios":"Calling execute/shutdown/shutdownNow/isShutdown/isTerminated/awaitTermination on the context-propagation-managed executor during static init or before runtime startup — e.g. running executor tasks from a @StaticInit-safe bean, build-time code, or early singleton init.","commonSituations":"Application logic touching the managed executor from a static initializer or startup bean initialized before runtime init; build steps invoking the executor directly instead of consuming ContextPropagationBuildItem.","solutions":["Defer executor usage until after runtime init (RuntimeInit shutdown/startup hooks, @Startup bean ordering, or observation of Started event)","In build-time code, consume the ContextPropagationBuildItem instead of touching the executor directly","Remove usage of the managed executor from static-init paths; use a plain executor there"],"exampleFix":"// before\n// static init:\ncontextExecutor.execute(task);\n// after\npublic void onStart(@Observes StartupEvent ev) {\n    contextExecutor.execute(task);\n}","handlingStrategy":"try-catch","validationCode":"if (isStaticInit() || !runtimeInitialized) {\n    throw new IllegalStateException(\"Executor not usable before runtime init\");\n}","typeGuard":null,"tryCatchPattern":"try { executor.execute(task); }\ncatch (RuntimeException e) {\n    if (e.getMessage().contains(\"partially-configured ContextManager\")) {\n        // defer to StartupEvent / ContextPropagationBuildItem\n    }\n}","preventionTips":["Never touch the managed executor in static init or before runtime init","Consume ContextPropagationBuildItem in build steps instead of calling the executor","Observe StartupEvent (or StartedEvent) before scheduling work","Use a plain executor for build-time/static-init work"],"tags":["context-propagation","lifecycle","static-init","executor"],"backgroundTag":"premature-init-usage","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"}