From 7841f900a2ccffb16fa5117694774e3163cc0b4e Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 14 Jan 2025 12:07:06 +0200 Subject: [PATCH] Close stream when client responds with an entity This shouldn't have an effect given the type of buffers we currently use, but if we change things in the future, this call will be necessary --- .../client/handlers/ClientResponseCompleteRestHandler.java | 3 +++ .../reactive/client/handlers/ClientSendRequestHandler.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientResponseCompleteRestHandler.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientResponseCompleteRestHandler.java index a862eb66704d4..53d97a8f6973b 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientResponseCompleteRestHandler.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientResponseCompleteRestHandler.java @@ -120,6 +120,9 @@ public static ResponseImpl mapToResponse(RestClientRequestContext context, if (entity != null) { builder.entity(entity); } + if (entity != null) { + entityStream.close(); + } } } } else { diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java index e326aa202e6e8..2d0392166403d 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java @@ -358,7 +358,7 @@ public void handle(AsyncResult ar) { try { if (buffer.length() > 0) { requestContext.setResponseEntityStream( - new ByteBufInputStream(buffer.getByteBuf())); + new ByteBufInputStream(buffer.getByteBuf(), true)); } else { requestContext.setResponseEntityStream(null); }