{"record":{"id":"f901b58930985f93","repo":"quarkusio/quarkus","slug":"this-executor-is-managed-by-the-container-and-cann","errorCode":null,"errorMessage":"This executor is managed by the container and cannot be shut down.","messagePattern":"This executor is managed by the container and cannot be shut down\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java","lineNumber":177,"sourceCode":"            @Override\n            public void run() {\n                contextManagerProvider.releaseContextManager(contextManager);\n            }\n        });\n        //Avoid leaking the classloader:\n        SmallRyeContextPropagationRecorder.builder = null;\n    }\n\n    public Supplier<Object> initializeManagedExecutor(ExecutorService executorService) {\n        return new Supplier<Object>() {\n            @Override\n            public Object get() {\n                ThreadContext threadContext = Arc.container().instance(ThreadContext.class).get();\n                return new SmallRyeManagedExecutor(-1, -1, (SmallRyeThreadContext) threadContext, executorService,\n                        \"no-ip\") {\n                    @Override\n                    public void shutdown() {\n                        throw new IllegalStateException(\"This executor is managed by the container and cannot be shut down.\");\n                    }\n\n                    @Override\n                    public List<Runnable> shutdownNow() {\n                        throw new IllegalStateException(\"This executor is managed by the container and cannot be shut down.\");\n                    }\n                };\n            }\n        };\n    }\n\n    public Supplier<Object> initializeConfiguredThreadContext(String[] cleared, String[] propagated, String[] unchanged) {\n        return new Supplier<Object>() {\n            @Override\n            public Object get() {\n                return ThreadContext.builder().propagated(propagated).cleared(cleared).unchanged(unchanged).build();\n            }\n        };","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java#L159-L195","documentation":"The container-managed executor exposed to applications is wrapped in a SmallRyeManagedExecutor whose shutdown() is overridden to throw IllegalStateException, because Quarkus owns the executor lifecycle and shutting it down would break the whole application. Shutdown attempts must go through container shutdown, not application code.","triggerScenarios":"Calling shutdown() on the managed executor injected via ManagedExecutor/ThreadContext CDI beans provided by the context propagation extension (the 'no-ip' container executor).","commonSituations":"Porting code that shuts down its own executor into Quarkus; cleanup code in a filter or @PreDestroy calling shutdown on the injected ManagedExecutor; libraries that manage lifecycle of executors passed to them.","solutions":["Remove the shutdown() call — the container shuts the executor down itself","If you need an application-owned executor, create your own ManagedExecutor via ManagedExecutorBuilder/instance config rather than the container one","Pass your own executor to third-party libraries that call shutdown on what they are given"],"exampleFix":"// before\n@Inject ManagedExecutor executor;\nvoid cleanup() { executor.shutdown(); }\n// after\nvoid cleanup() {\n    // no shutdown needed: container-managed\n}","handlingStrategy":"try-catch","validationCode":"if (executor instanceof SmallRyeManagedExecutor sme && \"no-ip\".equals(sme.getName())) {\n    throw new IllegalStateException(\"Do not shut down container-managed executor\");\n}","typeGuard":null,"tryCatchPattern":"try { executor.shutdown(); }\ncatch (IllegalStateException e) { /* expected: container-managed — remove this call */ }","preventionTips":["Never call shutdown/shutdownNow on injected ManagedExecutor beans in Quarkus","Create a dedicated ManagedExecutor if you need lifecycle control","Pass container executors only to code that does not manage their lifecycle"],"tags":["executor","lifecycle","context-propagation","container-managed"],"backgroundTag":"container-managed-executor-shutdown","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"}