retry on ResponseProcessingException 99/118799/1
authorBENJAMIN, MAX <max.benjamin@att.com>
Thu, 4 Mar 2021 15:14:40 +0000 (10:14 -0500)
committerAT&T Open Source <g22940@att.com>
Thu, 4 Mar 2021 15:14:41 +0000 (10:14 -0500)
retry on ResponseProcessingException

Issue-ID: SO-3570
Signed-off-by: AT&T Open Source <g22940@att.com>
Change-Id: I62745d3833bec8fb5f33007aa613ff4626b5486d

common/src/main/java/org/onap/so/client/RestClient.java
common/src/test/java/org/onap/so/client/RestClientTest.java

index d1b4c2b..0df378d 100644 (file)
@@ -248,7 +248,7 @@ public abstract class RestClient {
             return e.getCause() instanceof ConnectException;
         });
         result.add(e -> {
-            return e.getCause() instanceof ResponseProcessingException;
+            return e instanceof ResponseProcessingException;
         });
         return result;
     }
index 3bf4ccf..b5efa17 100644 (file)
@@ -34,9 +34,11 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Optional;
+import javax.net.ssl.SSLException;
 import javax.ws.rs.NotFoundException;
 import javax.ws.rs.ProcessingException;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ResponseProcessingException;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriBuilderException;
@@ -80,6 +82,20 @@ public class RestClientTest {
 
     }
 
+    @Test
+    public void retryOnChunkedNetworkIssue() throws Exception {
+        RestClient spy = buildSpy();
+        doThrow(new ResponseProcessingException(null, "something something", new SSLException("wow"))).when(spy)
+                .buildRequest(any(String.class), ArgumentMatchers.isNull());
+        try {
+            spy.get();
+        } catch (Exception e) {
+            // ignore this exception for this test
+        }
+        verify(spy, times(3)).buildRequest(any(String.class), ArgumentMatchers.isNull());
+
+    }
+
     @Test
     public void exceptionDoNotRetry() throws Exception {
         RestClient spy = buildSpy();