Skip to content

Commit

Permalink
Honor read timeout in reactive rest client
Browse files Browse the repository at this point in the history
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
  • Loading branch information
geoand committed Aug 4, 2021
1 parent 4fa14ec commit 8119002
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ public Future<HttpClientRequest> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -197,8 +195,8 @@ private <T> T unwrap(CompletableFuture<T> 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) {
Expand Down

0 comments on commit 8119002

Please sign in to comment.