aboutsummaryrefslogtreecommitdiffstats
path: root/jaxrs_client_utils
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-01-11 16:22:00 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-01-11 16:22:00 +0100
commit2217b91fde11b3a4a73cc611767bb473e8b73958 (patch)
treea123f047f2424a43e38ecceba1a2ef7e8a31fd23 /jaxrs_client_utils
parent6641837cdb3f4bc9d06fde2d85072197b066b73e (diff)
Retry WebApplicationExceptions as well
Diffstat (limited to 'jaxrs_client_utils')
-rw-r--r--jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/RetryingJaxRsStrategy.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/RetryingJaxRsStrategy.java b/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/RetryingJaxRsStrategy.java
index c964dfce2c7..00c3d296e52 100644
--- a/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/RetryingJaxRsStrategy.java
+++ b/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/RetryingJaxRsStrategy.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.jaxrs.client;
import com.yahoo.vespa.applicationmodel.HostName;
import javax.ws.rs.ProcessingException;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.net.URI;
@@ -73,7 +74,7 @@ public class RetryingJaxRsStrategy<T> implements JaxRsStrategy<T> {
@Override
public <R> R apply(final Function<T, R> function, JaxRsTimeouts timeouts) throws IOException {
- ProcessingException sampleException = null;
+ RuntimeException sampleException = null;
for (int i = 0; i < maxIterations; ++i) {
for (final HostName hostName : hostNames) {
@@ -84,8 +85,9 @@ public class RetryingJaxRsStrategy<T> implements JaxRsStrategy<T> {
final T jaxRsClient = jaxRsClientFactory.createClient(params);
try {
return function.apply(jaxRsClient);
- } catch (ProcessingException e) {
- // E.g. java.net.SocketTimeoutException thrown on read timeout is wrapped as a ProcessingException
+ } catch (ProcessingException | WebApplicationException e) {
+ // E.g. java.net.SocketTimeoutException thrown on read timeout is wrapped as a ProcessingException,
+ // while ServiceUnavailableException is a WebApplicationException
sampleException = e;
logger.log(Level.INFO, "Failed REST API call to "
+ hostName + ":" + port + pathPrefix + " (in retry loop): "