From 08e5c3106ce4bfb18b24a38514eeba6464668b07 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Tue, 26 Jul 2022 22:56:04 +1000 Subject: [PATCH] GraphQL to terminate the request even if it was active Signed-off-by: Phillip Kruger --- .../SmallRyeGraphQLAbstractHandler.java | 26 ++++++++----------- .../SmallRyeGraphQLExecutionHandler.java | 4 +-- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java index f0df7f5932297..b6f44d441a318 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java @@ -58,22 +58,18 @@ public void handle(Object e) { @Override public void handle(final RoutingContext ctx) { - if (currentManagedContext.isActive()) { - handleWithIdentity(ctx); - } else { - + ctx.response() + .endHandler(currentManagedContextTerminationHandler) + .exceptionHandler(currentManagedContextTerminationHandler) + .closeHandler(currentManagedContextTerminationHandler); + if (!currentManagedContext.isActive()) { currentManagedContext.activate(); - ctx.response() - .endHandler(currentManagedContextTerminationHandler) - .exceptionHandler(currentManagedContextTerminationHandler) - .closeHandler(currentManagedContextTerminationHandler); - - try { - handleWithIdentity(ctx); - } catch (Throwable t) { - currentManagedContext.terminate(); - throw t; - } + } + try { + handleWithIdentity(ctx); + } catch (Throwable t) { + currentManagedContext.terminate(); + throw t; } } diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java index d153c2c9572b9..7ff8e8d403998 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java @@ -196,8 +196,8 @@ private JsonObject getJsonObjectFromBody(RoutingContext ctx) throws IOException } private String readBody(RoutingContext ctx) { - if (ctx.getBody() != null) { - return ctx.getBodyAsString(); + if (ctx.body() != null) { + return ctx.body().asString(); } return null; }