From 7de4dccf0eeb8eb92b237a33d64781625d9a418f Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 9 Oct 2023 14:02:58 +0300 Subject: [PATCH] Properly handle invalid response body errors in Reactive REST Client Fixes: #36257 --- .../handlers/ClientSendRequestHandler.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) 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 385da9940a9ed..06f916d109038 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 @@ -322,22 +322,27 @@ public void handle(AsyncResult flushed) { new VertxClientInputStream(clientResponse, 100000, requestContext)); requestContext.resume(); } else { - clientResponse.bodyHandler(new Handler<>() { + clientResponse.body(new Handler<>() { @Override - public void handle(Buffer buffer) { - if (loggingScope != LoggingScope.NONE) { - clientLogger.logResponse(clientResponse, false); - } - try { - if (buffer.length() > 0) { - requestContext.setResponseEntityStream( - new ByteArrayInputStream(buffer.getBytes())); - } else { - requestContext.setResponseEntityStream(null); + public void handle(AsyncResult ar) { + if (ar.succeeded()) { + if (loggingScope != LoggingScope.NONE) { + clientLogger.logResponse(clientResponse, false); + } + Buffer buffer = ar.result(); + try { + if (buffer.length() > 0) { + requestContext.setResponseEntityStream( + new ByteArrayInputStream(buffer.getBytes())); + } else { + requestContext.setResponseEntityStream(null); + } + requestContext.resume(); + } catch (Throwable t) { + requestContext.resume(t); } - requestContext.resume(); - } catch (Throwable t) { - requestContext.resume(t); + } else { + requestContext.resume(ar.cause()); } } });