From 47076249aa322433abc3d200f7fd5237e0cfc4c5 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 1 May 2024 10:13:22 +1000 Subject: [PATCH] Don't close connection if response is sent Fixes #37323 --- .../reactive/server/core/ResteasyReactiveRequestContext.java | 4 +++- .../server/vertx/VertxResteasyReactiveRequestContext.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java index 657599ca1a9572..4d288748ef627c 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/ResteasyReactiveRequestContext.java @@ -640,7 +640,9 @@ protected void handleUnrecoverableError(Throwable throwable) { protected void endResponse() { if (serverResponse().headWritten()) { - serverRequest().closeConnection(); + if (!serverResponse().closed()) { + serverRequest().closeConnection(); + } } else { serverResponse().setStatusCode(500).end(); } diff --git a/independent-projects/resteasy-reactive/server/vertx/src/main/java/org/jboss/resteasy/reactive/server/vertx/VertxResteasyReactiveRequestContext.java b/independent-projects/resteasy-reactive/server/vertx/src/main/java/org/jboss/resteasy/reactive/server/vertx/VertxResteasyReactiveRequestContext.java index 0e02e22bb1b004..d6a097ed92312b 100644 --- a/independent-projects/resteasy-reactive/server/vertx/src/main/java/org/jboss/resteasy/reactive/server/vertx/VertxResteasyReactiveRequestContext.java +++ b/independent-projects/resteasy-reactive/server/vertx/src/main/java/org/jboss/resteasy/reactive/server/vertx/VertxResteasyReactiveRequestContext.java @@ -406,7 +406,7 @@ public void removeResponseHeader(String name) { @Override public boolean closed() { - return response.closed(); + return response.ended() || response.closed(); } @Override