Skip to content

Commit

Permalink
Merge pull request #26983 from michalvavrik/feature/graphql-checked-c…
Browse files Browse the repository at this point in the history
…ontext-termination-handler

Smallrye GraphQL - refactor context termination handler
gsmet authored Aug 1, 2022
2 parents 73c67d4 + aa2d324 commit 20280ff
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@ public abstract class SmallRyeGraphQLAbstractHandler implements Handler<RoutingC
private final CurrentIdentityAssociation currentIdentityAssociation;
private final CurrentVertxRequest currentVertxRequest;
private final ManagedContext currentManagedContext;
private final Handler currentManagedContextTerminationHandler;
private final Handler<Void> currentManagedContextTerminationHandler;
private final Handler<Throwable> currentManagedContextExceptionHandler;
private final boolean runBlocking;

private volatile ExecutionService executionService;
@@ -47,12 +48,16 @@ public SmallRyeGraphQLAbstractHandler(
this.currentVertxRequest = currentVertxRequest;
this.currentManagedContext = Arc.container().requestContext();
this.runBlocking = runBlocking;
this.currentManagedContextTerminationHandler = new Handler() {
this.currentManagedContextTerminationHandler = createCurrentManagedContextTerminationHandler();
this.currentManagedContextExceptionHandler = createCurrentManagedContextTerminationHandler();
}

private <T> Handler<T> createCurrentManagedContextTerminationHandler() {
return new Handler<>() {
@Override
public void handle(Object e) {
currentManagedContext.terminate();
}

};
}

@@ -61,7 +66,7 @@ public void handle(final RoutingContext ctx) {

ctx.response()
.endHandler(currentManagedContextTerminationHandler)
.exceptionHandler(currentManagedContextTerminationHandler)
.exceptionHandler(currentManagedContextExceptionHandler)
.closeHandler(currentManagedContextTerminationHandler);
if (!currentManagedContext.isActive()) {
currentManagedContext.activate();

0 comments on commit 20280ff

Please sign in to comment.