{"record":{"id":"1c05a36a1fc2c2b1","repo":"quarkusio/quarkus","slug":"shutdownnow-not-allowed-on-managed-executor-servic","errorCode":null,"errorMessage":"shutdownNow not allowed on managed executor service","messagePattern":"shutdownNow not allowed on managed executor service","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/virtual-threads/runtime/src/main/java/io/quarkus/virtual/threads/DelegatingExecutorService.java","lineNumber":43,"sourceCode":"        // container managed executors are never shut down from the application's perspective\n        return false;\n    }\n\n    public boolean isTerminated() {\n        // container managed executors are never shut down from the application's perspective\n        return false;\n    }\n\n    public boolean awaitTermination(final long timeout, final TimeUnit unit) {\n        return false;\n    }\n\n    public void shutdown() {\n        throw new UnsupportedOperationException(\"shutdown not allowed on managed executor service\");\n    }\n\n    public List<Runnable> shutdownNow() {\n        throw new UnsupportedOperationException(\"shutdownNow not allowed on managed executor service\");\n    }\n\n    public String toString() {\n        return delegate.toString();\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":50,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/virtual-threads/runtime/src/main/java/io/quarkus/virtual/threads/DelegatingExecutorService.java#L25-L50","documentation":"Same lifecycle restriction as shutdown(): DelegatingExecutorService.shutdownNow() throws UnsupportedOperationException because the wrapped executor is Quarkus-managed and must not be forcibly terminated by application code. Additionally note shutdownNow's return value (pending tasks) can never be provided for a managed pool.","triggerScenarios":"Calling shutdownNow() on the injected managed/virtual-thread executor service, typically during app shutdown or task cancellation logic.","commonSituations":"Code that cancels in-flight work at shutdown; third-party libraries that call shutdownNow() on an ExecutorService handed to them.","solutions":["Drop the shutdownNow() call; let Quarkus manage executor termination","Use an application-created executor for components that need to force shutdown","Use a completion flag/Future.cancel(true) per task instead of shutting down the whole pool"],"exampleFix":"// before\nList<Runnable> pending = executor.shutdownNow();\n// after\nfuture.cancel(true); // cancel individual tasks instead","handlingStrategy":"validation","validationCode":"if (isQuarkusManaged(executor)) { /* never call shutdownNow */ }","typeGuard":"boolean isManagedExecutor(ExecutorService es) { return es.getClass().getName().startsWith(\"io.quarkus.virtual.threads\"); }","tryCatchPattern":"try { executor.shutdownNow(); } catch (UnsupportedOperationException ignored) { /* managed by Quarkus */ }","preventionTips":["Cancel individual tasks via Future.cancel instead of pool shutdown","Own the executor lifecycle yourself when you need shutdownNow semantics","Review third-party components for implicit executor shutdown"],"tags":["virtual-threads","executor","lifecycle","unsupported-operation"],"backgroundTag":"shutdown-not-allowed-on-managed-executor","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"}