Package se.michaelthelin.spotify
Class SpotifyHttpRequestRetryStrategy
java.lang.Object
se.michaelthelin.spotify.SpotifyHttpRequestRetryStrategy
- All Implemented Interfaces:
org.apache.hc.client5.http.HttpRequestRetryStrategy
@Contract(threading=STATELESS)
public class SpotifyHttpRequestRetryStrategy
extends Object
implements org.apache.hc.client5.http.HttpRequestRetryStrategy
Default implementation of the
HttpRequestRetryStrategy
interface.- Since:
- 5.0
-
Constructor Summary
ModifierConstructorDescriptionCreate the HTTP request retry strategy with a max retry count of 1, default retry interval of 1 second, and using the following list of non-retriable I/O exception classes:
InterruptedIOException UnknownHostException ConnectException ConnectionClosedException SSLExceptionSpotifyHttpRequestRetryStrategy
(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval) Create the HTTP request retry strategy using the following list of non-retriable I/O exception classes:
InterruptedIOException UnknownHostException ConnectException ConnectionClosedException NoRouteToHostException SSLExceptionprotected
SpotifyHttpRequestRetryStrategy
(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval, Collection<Class<? extends IOException>> clazzes, Collection<Integer> codes) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.util.TimeValue
getRetryInterval
(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) protected boolean
handleAsIdempotent
(org.apache.hc.core5.http.HttpRequest request) boolean
retryRequest
(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) boolean
retryRequest
(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hc.client5.http.HttpRequestRetryStrategy
getRetryInterval
-
Constructor Details
-
SpotifyHttpRequestRetryStrategy
protected SpotifyHttpRequestRetryStrategy(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval, Collection<Class<? extends IOException>> clazzes, Collection<Integer> codes) -
SpotifyHttpRequestRetryStrategy
public SpotifyHttpRequestRetryStrategy(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval) Create the HTTP request retry strategy using the following list of non-retriable I/O exception classes:
- InterruptedIOException
- UnknownHostException
- ConnectException
- ConnectionClosedException
- NoRouteToHostException
- SSLException
and retriable HTTP status codes:
- SC_SERVICE_UNAVAILABLE (503)
- Parameters:
maxRetries
- how many times to retry; 0 means no retriesdefaultRetryInterval
- the default retry interval between subsequent retries if theRetry-After
header is not set or invalid.
-
SpotifyHttpRequestRetryStrategy
public SpotifyHttpRequestRetryStrategy()Create the HTTP request retry strategy with a max retry count of 1, default retry interval of 1 second, and using the following list of non-retriable I/O exception classes:
- InterruptedIOException
- UnknownHostException
- ConnectException
- ConnectionClosedException
- SSLException
and retriable HTTP status codes:
- SC_SERVICE_UNAVAILABLE (503)
-
-
Method Details
-
retryRequest
public boolean retryRequest(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) - Specified by:
retryRequest
in interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy
-
retryRequest
public boolean retryRequest(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) - Specified by:
retryRequest
in interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy
-
getRetryInterval
public org.apache.hc.core5.util.TimeValue getRetryInterval(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) - Specified by:
getRetryInterval
in interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy
-
handleAsIdempotent
protected boolean handleAsIdempotent(org.apache.hc.core5.http.HttpRequest request)
-