diff --git a/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationTemplate.java b/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationTemplate.java index d6d4a48b668b5..79ee7e860637a 100644 --- a/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationTemplate.java +++ b/extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/SmallRyeContextPropagationTemplate.java @@ -23,10 +23,17 @@ public class SmallRyeContextPropagationTemplate { public void configureStaticInit(List discoveredProviders, List discoveredExtensions) { // build the manager at static init time - ContextManagerProvider contextManagerProvider = new SmallRyeContextManagerProvider(); - ContextManagerProvider.register(contextManagerProvider); + try { + ContextManagerProvider.instance(); + // the previous line will throw if already configured + ContextManagerProvider contextManagerProvider = new SmallRyeContextManagerProvider(); + ContextManagerProvider.register(contextManagerProvider); + } catch (IllegalStateException ignored) { + // already set + } + // do what config we can here, but we need the runtime executor service to finish - builder = (SmallRyeContextManager.Builder) contextManagerProvider + builder = (SmallRyeContextManager.Builder) ContextManagerProvider.instance() .getContextManagerBuilder(); builder.withThreadContextProviders(discoveredProviders.toArray(new ThreadContextProvider[0])); builder.withContextManagerExtensions(discoveredExtensions.toArray(new ContextManagerExtension[0]));