From 24f05857d0b46abaf4578143e3cefb02eeab09d4 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Wed, 4 Aug 2021 15:04:23 +0300 Subject: [PATCH] Honor read timeout in reactive rest client Before this change the read timeout only had an effect when doing a synchronous call (and even then it didn't result in the proper Vert.x exception) The connect timeout handling doesn't need any changes because it is properly handled when org.jboss.resteasy.reactive.client.impl.ClientImpl is created Fixes: #17526 --- .../reactive/client/handlers/ClientSendRequestHandler.java | 4 ++++ .../reactive/client/impl/InvocationBuilderImpl.java | 6 ++---- 2 files changed, 6 insertions(+), 4 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 0c7517a29139f..62bed99697d57 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 @@ -166,6 +166,10 @@ public Future createRequest(RestClientRequestContext state) { requestOptions.setURI(uri.getPath() + (uri.getQuery() == null ? "" : "?" + uri.getQuery())); requestOptions.setFollowRedirects(followRedirects); requestOptions.setSsl(isHttps); + Object readTimeout = state.getConfiguration().getProperty(QuarkusRestClientProperties.READ_TIMEOUT); + if (readTimeout instanceof Long) { + requestOptions.setTimeout((Long) readTimeout); + } return httpClient.request(requestOptions); } diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java index f6e8ec865331c..5d34b20c78eeb 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java @@ -10,8 +10,6 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import javax.ws.rs.ProcessingException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.client.CompletionStageRxInvoker; @@ -197,8 +195,8 @@ private T unwrap(CompletableFuture c) { throw new BlockingNotAllowedException(); } try { - return c.get(readTimeoutMs, TimeUnit.MILLISECONDS); - } catch (InterruptedException | TimeoutException e) { + return c.get(); + } catch (InterruptedException e) { throw new ProcessingException(e); } catch (ExecutionException e) { if (e.getCause() instanceof ProcessingException) {