You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by mi...@apache.org on 2019/12/05 20:23:12 UTC

[httpcomponents-client] 06/08: Use HttpRequestRetryHandler if set

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

michaelo pushed a commit to branch HTTPCLIENT-2034
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit 047783409d1d1754677c44e08e2aa543fb85e34a
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Thu Dec 5 19:38:27 2019 +0100

    Use HttpRequestRetryHandler if set
---
 .../http/impl/classic/HttpClientBuilder.java       | 29 +++++++++++-----------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java
index 610e5ed..0dfef46 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java
@@ -61,7 +61,6 @@ import org.apache.hc.client5.http.impl.ChainElements;
 import org.apache.hc.client5.http.impl.CookieSpecSupport;
 import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy;
 import org.apache.hc.client5.http.impl.DefaultConnectionKeepAliveStrategy;
-import org.apache.hc.client5.http.impl.DefaultHttpRequestRetryHandler;
 import org.apache.hc.client5.http.impl.DefaultHttpRequestRetryStrategy;
 import org.apache.hc.client5.http.impl.DefaultRedirectStrategy;
 import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
@@ -873,21 +872,21 @@ public class HttpClientBuilder {
 
         // Add request retry executor, if not disabled
         if (!automaticRetriesDisabled) {
-            HttpRequestRetryHandler retryHandlerCopy = this.retryHandler;
-            if (retryHandlerCopy == null) {
-                retryHandlerCopy = DefaultHttpRequestRetryHandler.INSTANCE;
-            }
-            execChainDefinition.addFirst(
-                    new RetryExec(retryHandlerCopy),
-                    ChainElements.RETRY_IO_ERROR.name());
-
-            HttpRequestRetryStrategy retryStrategyCopy = this.retryStrategy;
-            if (retryStrategyCopy == null) {
-                retryStrategyCopy = DefaultHttpRequestRetryStrategy.INSTANCE;
+            // This needs to be cleaned up as soon as HttpRequestRetryHandler will be removed
+            final HttpRequestRetryHandler retryHandlerCopy = this.retryHandler;
+            if (retryHandlerCopy != null) {
+                execChainDefinition.addFirst(
+                        new RetryExec(retryHandlerCopy),
+                        ChainElements.RETRY_IO_ERROR.name());
+            } else {
+                HttpRequestRetryStrategy retryStrategyCopy = this.retryStrategy;
+                if (retryStrategyCopy == null) {
+                    retryStrategyCopy = DefaultHttpRequestRetryStrategy.INSTANCE;
+                }
+                execChainDefinition.addFirst(
+                        new HttpRequestRetryExec(retryStrategyCopy),
+                        ChainElements.RETRY.name());
             }
-            execChainDefinition.addFirst(
-                    new HttpRequestRetryExec(retryStrategyCopy),
-                    ChainElements.RETRY.name());
         }
 
         HttpRoutePlanner routePlannerCopy = this.routePlanner;