@Beta public class HttpBackOffIOExceptionHandler extends Objectimplements HttpIOExceptionHandler
Beta
HttpIOExceptionHandler implementation with
BackOff.
It is designed to work with only one HttpRequest at a time. As a result you MUST create a new instance of HttpBackOffIOExceptionHandler with a new instance of BackOff for each instance of HttpRequest.
Sample usage:
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff());
Note: Implementation doesn't call BackOff at all, since it expects a new BackOff instance.
Implementation is not thread-safe
| Constructor and Description |
|---|
HttpBackOffIOExceptionHandler(BackOff
Constructs a new instance from a
BackOff.
|
| Modifier and Type | Method and Description |
|---|---|
BackOff |
getBackOff()
Returns the back-off.
|
Sleeper |
getSleeper()
Returns the sleeper.
|
boolean |
handleIOException(HttpRequest
Invoked when an
IOException is thrown during an HTTP request.
|
HttpBackOffIOExceptionHandler |
setSleeper(Sleeper
Sets the sleeper.
|
public final BackOffgetBackOff()
public final SleepergetSleeper()
public HttpBackOffIOExceptionHandlersetSleeper(Sleeper sleeper)
The default value is Sleeper.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public boolean handleIOException(HttpRequestrequest, boolean supportsRetry) throws IOException
IOException is thrown during an HTTP request.
There is a simple rule that one must follow: If you modify the request object or modify its execute interceptors in a way that should resolve the error, you must return true to issue a retry.
Handles the request with BackOff. That means that if back-off is required a call to Sleeper will be made.
handleIOException in interface
HttpIOExceptionHandler
request - request object that can be read from for context or modified before retry
supportsRetry - whether there will actually be a retry if this handler return
true . Some handlers may want to have an effect only when there will actually be a retry after they handle their event (e.g. a handler that implements backoff policy).
IOException