Repository: quarkusio/quarkus
Issue: MP CP integration doesn't allow for user defined custom contexts

I came across this while investigating execution of MP CP TCK on Quarkus.
What the TCK does is define custom contexts (`ThreadContextProvider`s) that are registered via service loader mechanism.
Here is a [link](https://github.com/eclipse/microprofile-context-propagation/blob/master/tck/src/main/java/org/eclipse/microprofile/context/tck/ThreadContextTest.java#L113) to those TCK tests.

However, our current SR CP integration does an early initialization of `SmallRyeContextManager` with set of discovered contexts that is determined before user application is inspected.
The integration happens [here](https://github.com/quarkusio/quarkus/blob/master/extensions/smallrye-context-propagation/deployment/src/main/java/io/quarkus/smallrye/context/deployment/SmallRyeContextPropagationProcessor.java#L41-L49) and is executed as `STATIC_INIT` which is too early, at least for TCK case.
I am not sure how this would affect actual Quarkus app where users would attempt to do similar thing - I suspect it would be the same.

We are going to need some way to make a second round of `ThreadContextProvider` discovery, or perhaps feed that information directly into `SmallRyeContextManager`?

Ccing @FroMage 

Changed files:
extensions/smallrye-context-propagation/deployment/src/main/java/io/quarkus/smallrye/context/deployment/SmallRyeContextPropagationProcessor.java

diff --git a/extensions/smallrye-context-propagation/deployment/src/main/java/io/quarkus/smallrye/context/deployment/SmallRyeContextPropagationProcessor.java b/extensions/smallrye-context-propagation/deployment/src/main/java/io/quarkus/smallrye/context/deployment/SmallRyeContextPropagationProcessor.java
index 8d68e10e984..2bb1531edd0 100644
--- a/extensions/smallrye-context-propagation/deployment/src/main/java/io/quarkus/smallrye/context/deployment/SmallRyeContextPropagationProcessor.java
+++ b/extensions/smallrye-context-propagation/deployment/src/main/java/io/quarkus/smallrye/context/deployment/SmallRyeContextPropagationProcessor.java
@@ -38,7 +38,7 @@ void buildStatic(SmallRyeContextPropagationRecorder recorder)
             throws ClassNotFoundException, IOException {
         List<ThreadContextProvider> discoveredProviders = new ArrayList<>();
         List<ContextManagerExtension> discoveredExtensions = new ArrayList<>();
-        for (Class<?> provider : ServiceUtil.classesNamedIn(SmallRyeContextPropagationRecorder.class.getClassLoader(),
+        for (Class<?> provider : ServiceUtil.classesNamedIn(Thread.currentThread().getContextClassLoader(),
                 "META-INF/services/" + ThreadContextProvider.class.getName())) {
             try {
                 discoveredProviders.add((ThreadContextProvider) provider.newInstance());
@@ -47,7 +47,7 @@ void buildStatic(SmallRyeContextPropagationRecorder recorder)
                         e);
             }
         }
-        for (Class<?> extension : ServiceUtil.classesNamedIn(SmallRyeContextPropagationRecorder.class.getClassLoader(),
+        for (Class<?> extension : ServiceUtil.classesNamedIn(Thread.currentThread().getContextClassLoader(),
                 "META-INF/services/" + ContextManagerExtension.class.getName())) {
             try {
                 discoveredExtensions.add((ContextManagerExtension) extension.newInstance());