diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcThreadSetupAction.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcThreadSetupAction.java index a64d3ae4d7901..4d13a0db03c38 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcThreadSetupAction.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-common/runtime/src/main/java/io/quarkus/resteasy/reactive/common/runtime/ArcThreadSetupAction.java @@ -15,9 +15,7 @@ public ArcThreadSetupAction(ManagedContext managedContext) { @Override public ThreadState activateInitial() { - managedContext.activate(); - InjectableContext.ContextState state = managedContext.getState(); - return toThreadState(state); + return toThreadState(managedContext.activate()); } private ThreadState toThreadState(InjectableContext.ContextState state) { diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/QuarkusCurrentRequest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/QuarkusCurrentRequest.java index 3b9dc718b2ef6..08a42253a9666 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/QuarkusCurrentRequest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/QuarkusCurrentRequest.java @@ -25,14 +25,12 @@ public ResteasyReactiveRequestContext get() { public void set(ResteasyReactiveRequestContext set) { if (set == null) { try { - currentVertxRequest.setOtherHttpContextObject(null); - currentVertxRequest.setCurrent(null); + currentVertxRequest.setCurrent(null, null); } catch (ContextNotActiveException ignored) { // ignored because for HTTP pipelining it can already be closed } } else { - currentVertxRequest.setOtherHttpContextObject(set); - currentVertxRequest.setCurrent(set.unwrap(RoutingContext.class)); + currentVertxRequest.setCurrent(set.unwrap(RoutingContext.class), set); } } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/ManagedContext.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/ManagedContext.java index 114c5a5ebe0f9..4e7037255e73f 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/ManagedContext.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/ManagedContext.java @@ -10,19 +10,23 @@ public interface ManagedContext extends InjectableContext { /** * Activate the context with no initial state. + * + * @return the context state */ - default void activate() { - activate(null); + default ContextState activate() { + return activate(null); } /** * Activate the context. + *
* If invoked with {@code null} parameter, a fresh {@link io.quarkus.arc.InjectableContext.ContextState} is
* automatically created.
*
* @param initialState The initial state, may be {@code null}
+ * @return the context state
*/
- void activate(ContextState initialState);
+ ContextState activate(ContextState initialState);
/**
* Deactivate the context - do not destoy existing contextual instances.
diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/RequestContext.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/RequestContext.java
index 9e49206808bc9..e9296569b2643 100644
--- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/RequestContext.java
+++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/RequestContext.java
@@ -122,17 +122,20 @@ public void destroy(Contextual> contextual) {
}
@Override
- public void activate(ContextState initialState) {
+ public ContextState activate(ContextState initialState) {
if (LOG.isTraceEnabled()) {
traceActivate(initialState);
}
if (initialState == null) {
- currentContext.set(new RequestContextState(new ConcurrentHashMap<>()));
+ RequestContextState state = new RequestContextState(new ConcurrentHashMap<>());
+ currentContext.set(state);
// Fire an event with qualifier @Initialized(RequestScoped.class) if there are any observers for it
fireIfNotEmpty(initializedNotifier);
+ return state;
} else {
if (initialState instanceof RequestContextState) {
currentContext.set((RequestContextState) initialState);
+ return initialState;
} else {
throw new IllegalArgumentException("Invalid initial state: " + initialState.getClass().getName());
}
diff --git a/independent-projects/arc/tcks/cdi-tck-porting-pkg/src/main/java/io/quarkus/arc/tck/porting/ContextsImpl.java b/independent-projects/arc/tcks/cdi-tck-porting-pkg/src/main/java/io/quarkus/arc/tck/porting/ContextsImpl.java
index d87675bfa11ae..cd40e5f058c5e 100644
--- a/independent-projects/arc/tcks/cdi-tck-porting-pkg/src/main/java/io/quarkus/arc/tck/porting/ContextsImpl.java
+++ b/independent-projects/arc/tcks/cdi-tck-porting-pkg/src/main/java/io/quarkus/arc/tck/porting/ContextsImpl.java
@@ -19,15 +19,27 @@ public class ContextsImpl implements Contexts