From ad11e637bc4b4e07c06e389f2aaea191b1c16e7f Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 8 Sep 2021 15:48:00 +1000 Subject: [PATCH] Release the context manager last Still running threads can re-create an implicit one --- .../context/runtime/SmallRyeContextPropagationRecorder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java b/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java index 2c541aceada9c..86179875d4ec4 100644 --- a/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java +++ b/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationRecorder.java @@ -50,7 +50,8 @@ public void configureRuntime(ExecutorService executorService, ShutdownContext sh SmallRyeContextManager contextManager = builder.build(); contextManagerProvider.registerContextManager(contextManager, Thread.currentThread().getContextClassLoader()); - shutdownContext.addShutdownTask(new Runnable() { + //needs to be late, as running threads can re-create an implicit one + shutdownContext.addLastShutdownTask(new Runnable() { @Override public void run() { contextManagerProvider.releaseContextManager(contextManager);