Skip to content

Commit

Permalink
Only activate request context in RESTEasy Reactive if it's not alread…
Browse files Browse the repository at this point in the history
…y active

Fixes: quarkusio#34693
  • Loading branch information
geoand committed Jul 13, 2023
1 parent 26cb1bd commit 41b11da
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ public ArcThreadSetupAction(ManagedContext managedContext) {

@Override
public ThreadState activateInitial() {
managedContext.activate();
boolean wasActiveBefore = managedContext.isActive();
if (!wasActiveBefore) {
managedContext.activate();
}
InjectableContext.ContextState state = managedContext.getState();
return toThreadState(state);
return toThreadState(state, wasActiveBefore);
}

private ThreadState toThreadState(InjectableContext.ContextState state) {
private ThreadState toThreadState(InjectableContext.ContextState state, boolean wasActiveBefore) {
return new ThreadState() {
@Override
public void close() {
managedContext.destroy(state);
if (!wasActiveBefore) {
managedContext.destroy(state);
}
}

@Override
Expand All @@ -41,6 +46,6 @@ public void deactivate() {

@Override
public ThreadState currentState() {
return toThreadState(managedContext.getState());
return toThreadState(managedContext.getState(), false);
}
}

0 comments on commit 41b11da

Please sign in to comment.