You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (Jira)" <ji...@apache.org> on 2024/04/18 08:55:00 UTC

[jira] [Commented] (HTTPCLIENT-2326) Support any Exception in RetryStrategy

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-2326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17838539#comment-17838539 ] 

Oleg Kalnichevski commented on HTTPCLIENT-2326:
-----------------------------------------------

[~ofrias] What I would like  to propose is that `TunnelRefusedException ` would get routed to the `HttpRequestRetryStrategy#retryRequest` that takes `HttpResponse` as a parameter.

Oleg

> Support any Exception in RetryStrategy
> --------------------------------------
>
>                 Key: HTTPCLIENT-2326
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2326
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>            Reporter: Oscar
>            Priority: Minor
>
> It would be useful to modify {{HttpRequestRetryExec}} to allow {{HttpRequestRetryStrategy}} to support all kind of exceptions, not only those extending {{{}IOException{}}}.
> I would like HttpClient to retry requests when facing a [TunnelRefusedException|https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/TunnelRefusedException.html] (it happens randomly that the proxy refuses the initial connection, but it usually works ok when retrying).
> I have tried extending [DefaultHttpRequestRetryStrategy|https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java] but it can only capture exceptions inheriting from {{IOException.}}
> So, maybe {{HttpRequestRetryStrategy}} interface should support any kind of {{Exception }} or maybe {{TunnelRefusedException}} should be an {{IOException}}
>  
> This is an example of a stacktrace that I would like to retry:
>  
> {code:java}
> org.apache.hc.client5.http.ClientProtocolException: CONNECT refused by proxy: HTTP/1.1 500 Internal Server Error
> at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:173)
> at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
> at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
> [...]
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
> at java.base/java.lang.Thread.run(Thread.java:1583)
> Caused by: org.apache.hc.client5.http.impl.TunnelRefusedException: CONNECT refused by proxy: HTTP/1.1 500 Internal Server Error
> at org.apache.hc.client5.http.impl.classic.ConnectExec.createTunnelToTarget(ConnectExec.java:284)
> at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:151)
> at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
> at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
> at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
> at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
> at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
> at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
> at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
> at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
> at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
> at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170){code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org