diff --git a/core/src/main/java/io/smallrye/context/SmallRyeManagedExecutor.java b/core/src/main/java/io/smallrye/context/SmallRyeManagedExecutor.java index 3e91314d..44351fb9 100644 --- a/core/src/main/java/io/smallrye/context/SmallRyeManagedExecutor.java +++ b/core/src/main/java/io/smallrye/context/SmallRyeManagedExecutor.java @@ -24,6 +24,8 @@ public class SmallRyeManagedExecutor implements ManagedExecutor { + private static final String UNI_APPLY = "java.util.concurrent.CompletableFuture$UniApply"; + private final SmallRyeThreadContext threadContext; private final int maxAsync; private final int maxQueued; @@ -139,6 +141,12 @@ public T invokeAny(Collection> tasks, long timeout, Ti @Override public void execute(Runnable command) { + if (UNI_APPLY.equals(command.getClass().getName())) { + // no need to contextualize this case as this class can only be created internally by the JDK + // not by the user. It is created when a completeableFuture.thenApplyAsync is used + executeWithoutPropagation(command); + return; + } executor.execute(threadContext.contextualRunnableUnlessContextualized(command)); }