wildfly-extras / wildfly-mp-reactive-feature-pack

A galleon feature pack to add the MicroProfile reactive subsystems to your WildFly installation
Apache License 2.0
2 stars 10 forks source link

(RxJava2)Propagators are lazily initialised on first Context Propagation use #10

Open kabir opened 4 years ago

kabir commented 4 years ago

The initialisation of the SmallRyeManager seems to happen on first call of injected ManagedExecutor and ThreadContext instances (and first use of their builders). This in turn adds the ContextManagerExtensions, of which the RxJava2Propagator is one.

So with the following endpoint:

@GET
public Publisher<String> testPublisher() throws SystemException {
       //1
        System.out.println(Flowable.fromArray("X").getClass());
       //2
        ThreadContext.builder().propagated(ThreadContext.ALL_REMAINING).build();
       //3
        System.out.println(Flowable.fromArray("X").getClass());

2 does the initialisation of the SmallRye context manager. The Flowable in 1 is a 'plain' one, and 3 is one which supports context propagation.

This might be an acceptable limitation since the Publisher stuff is a nice to have.

But perhaps the ContextPropagation deployers should do something to eagerly initialise this? Would there be some ramifications of doing this?

kabir commented 4 years ago

If I comment out all methods in Quarkus's SimpleContextPropagationTest apart from testTransactionContextPropagationPublisher() I end up with something similar to the example (it comes from trying to port that test). In Quarkus it works