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
ConstructorsModifierConstructorDescriptionCreate 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 SSLExceptionprotectedSpotifyHttpRequestRetryStrategy(int maxRetries, org.apache.hc.core5.util.TimeValue defaultRetryInterval, Collection<Class<? extends IOException>> clazzes, Collection<Integer> codes) Protected constructor for creating a new SpotifyHttpRequestRetryStrategy. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.util.TimeValuegetRetryInterval(org.apache.hc.core5.http.HttpResponse response, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) protected booleanhandleAsIdempotent(org.apache.hc.core5.http.HttpRequest request) Determines if the given HTTP request should be handled as idempotent.booleanretryRequest(org.apache.hc.core5.http.HttpRequest request, IOException exception, int execCount, org.apache.hc.core5.http.protocol.HttpContext context) booleanretryRequest(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, waitMethods 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) Protected constructor for creating a new SpotifyHttpRequestRetryStrategy.- Parameters:
maxRetries- the maximum number of retriesdefaultRetryInterval- the default retry intervalclazzes- collection of exception classes that should trigger retriescodes- collection of HTTP status codes that should trigger retries
-
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-Afterheader 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:
retryRequestin 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:
retryRequestin 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:
getRetryIntervalin interfaceorg.apache.hc.client5.http.HttpRequestRetryStrategy
-
handleAsIdempotent
protected boolean handleAsIdempotent(org.apache.hc.core5.http.HttpRequest request) Determines if the given HTTP request should be handled as idempotent.- Parameters:
request- the HTTP request to check- Returns:
- true if the request should be treated as idempotent, false otherwise
-