smallrye / smallrye-fault-tolerance

SmallRye implementation of MicroProfile Fault Tolerance: bulkheads, circuit breakers, fallbacks, rate limits, retries, timeouts, and more
Apache License 2.0
85 stars 36 forks source link

should request context be force-activated for @Asynchronous methods if context propagation is used? #352

Open Ladicek opened 3 years ago

Ladicek commented 3 years ago

When MicroProfile Context Propagation integration is not enabled, SmallRye Fault Tolerance obeys the MicroProfile Fault Tolerance specification and always activates the CDI request context for @Asynchronous method invocations.

However, when MicroProfile Context Propagation integration is enabled, we leave everything to Context Propagation. This means that if the request context is not active on the original thread, it isn't active during the @Asynchronous method invocation either. This is contrary to the spec, but makes more sense from the Context Propagation perspective.

I have implemented a fix that enforces request context activation even in presence of Context Propagation integration, but I'm not sure if that's correct. I tend to think that the current behavior is more appropriate, but we can debate it here.

(Note that in Quarkus, SmallRye Fault Tolerance always has the Context Propagation integration enabled.)

Ladicek commented 3 years ago

Note to self: comes from this discussion: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Microprofile.20.40Asynchronous.20when.20RequestScoped.20is.20not.20active