Implementations of clearAndSet() method from WeldAlterableContext have to invoke RequestScopedCache.invalidate(). This makes sure the ThreadLocal caches for request/session/conversation scopes are flushed. This isn't normally a problem if you propagate contexts into a different thread. However, if you temper with context states on the same (main) thread, you will now end up in a weird state where context storage is empty, but caches still return old references. This scenario is from MP Concurrency where there is no guarantee which thread will be used for execution. A workaround is to manually invoke RequestScopedCache.invalidate() whenever integrator deals with propagation as the method is static. Though this requires weld-core dependency. |