Thomas Warner created HTTPCLIENT-2114:
-----------------------------------------

             Summary: AsyncHttpRequestRetryExec ignores 
HttpRequestRetryStrategy 
                 Key: HTTPCLIENT-2114
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2114
             Project: HttpComponents HttpClient
          Issue Type: Improvement
          Components: HttpClient (async)
    Affects Versions: 5.0.1
            Reporter: Thomas Warner


It is noted in the Javadoc that AsyncHttpRequestRetryExec does not respect 
[{{HttpRequestRetryStrategy.getRetryInterval()}}|https://hc.apache.org/httpcomponents-client-5.0.x/httpclient5/apidocs/org/apache/hc/client5/http/HttpRequestRetryStrategy.html#getRetryInterval(org.apache.hc.core5.http.HttpResponse,%20int,%20org.apache.hc.core5.http.protocol.HttpContext)]

Instead, the request is retried instantly. The immediate retry happens for both 
IOException retries and server responses with 429 and 503 status codes. The 
Retry-After header is also ignored due to this issue. Retrying instantly is not 
desirable, especially and can actively make the situation worse.

The most relevant code block is in the completed() method of the 
AsyncExecCallback that is created. If the request is meant to be retried, 
AsyncHttpRequestRetryExec immediately calls the internalExecute() method to 
retry the request.

A naive approach would be to add to the internal State class a field for a 
TimeValue representing the delay for the request. In handleResponse(), the 
response from  retryStrategy.retryRequest() could be stored in the state object 
and then in completed(), you could call TimeValue.sleep() on that property. 
However, I imagine this has the potential to lock up resources for a 
significant amount of time.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to