From fc801a2cf5098f09e21b106e99b3060bb201cbd6 Mon Sep 17 00:00:00 2001 From: Clement Escoffier Date: Fri, 1 Apr 2022 18:11:34 +0200 Subject: [PATCH] Ensure that the request handler are invoked on a duplication context, even when receiving pipelined requests. This is a 'temporary(tm)' workaround, as the issue most probably lies in Vert.x. It fixes https://github.com/quarkusio/quarkus/issues/24626 --- .../vertx/http/runtime/VertxHttpRecorder.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index e9616ef08ad63..cfb398cc681d5 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -501,8 +501,22 @@ public void handle(HttpServerRequest event) { root = new Handler() { @Override public void handle(HttpServerRequest event) { - setCurrentContextSafe(true); - delegate.handle(new ResumingRequestWrapper(event)); + if (!VertxContext.isOnDuplicatedContext()) { + // Vert.x should call us on a duplicated context. + // But in the case of pipelined requests, it does not. + // See https://github.com/quarkusio/quarkus/issues/24626. + Context context = VertxContext.createNewDuplicatedContext(); + context.runOnContext(new Handler() { + @Override + public void handle(Void x) { + setCurrentContextSafe(true); + delegate.handle(new ResumingRequestWrapper(event)); + } + }); + } else { + setCurrentContextSafe(true); + delegate.handle(new ResumingRequestWrapper(event)); + } } }; if (httpConfiguration.recordRequestStartTime) {