You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/08/23 20:26:11 UTC

[httpcomponents-client] branch 5.1.x updated: Don't retry a request for NoRouteToHostException

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.1.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/5.1.x by this push:
     new ec096ea  Don't retry a request for NoRouteToHostException
ec096ea is described below

commit ec096ea0f2390039eab23868de478b9c699593c6
Author: Jaikiran Pai <ja...@gmail.com>
AuthorDate: Sun Aug 22 19:17:57 2021 +0530

    Don't retry a request for NoRouteToHostException
---
 .../hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java     | 3 +++
 .../hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java
index 2f8695a..b1be581 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java
@@ -30,6 +30,7 @@ package org.apache.hc.client5.http.impl;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.net.ConnectException;
+import java.net.NoRouteToHostException;
 import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.Collection;
@@ -106,6 +107,7 @@ public class DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy
      * <li>UnknownHostException</li>
      * <li>ConnectException</li>
      * <li>ConnectionClosedException</li>
+     * <li>NoRouteToHostException</li>
      * <li>SSLException</li>
      * </ul>
      *
@@ -129,6 +131,7 @@ public class DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy
                         UnknownHostException.class,
                         ConnectException.class,
                         ConnectionClosedException.class,
+                        NoRouteToHostException.class,
                         SSLException.class),
                 Arrays.asList(
                         HttpStatus.SC_TOO_MANY_REQUESTS,
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java
index 0411326..fc8c575 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java
@@ -28,6 +28,7 @@ package org.apache.hc.client5.http.impl;
 
 import java.io.IOException;
 import java.net.ConnectException;
+import java.net.NoRouteToHostException;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 import java.util.Date;
@@ -127,6 +128,13 @@ public class TestDefaultHttpRequestRetryStrategy {
     }
 
     @Test
+    public void noRetryForNoRouteToHostException() {
+        final HttpGet request = new HttpGet("/");
+
+        Assert.assertFalse(retryStrategy.retryRequest(request, new NoRouteToHostException(), 1, null));
+    }
+
+    @Test
     public void noRetryOnSSLFailure() throws Exception {
         final HttpGet request = new HttpGet("/");