Skip to content

Commit

Permalink
context propagation restart fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michalszynkiewicz committed May 28, 2019
1 parent f438459 commit 2826929
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ public class SmallRyeContextPropagationTemplate {
public void configureStaticInit(List<ThreadContextProvider> discoveredProviders,
List<ContextManagerExtension> 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]));
Expand Down

0 comments on commit 2826929

Please sign in to comment.