Class HttpBackOffIOExceptionHandler
- All Implemented Interfaces:
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.reset()
at all, since it expects a new BackOff
instance.
Implementation is not thread-safe
- Since:
- 1.15
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpBackOffIOExceptionHandler
(BackOff backOff) Constructs a new instance from aBackOff
. -
Method Summary
Modifier and TypeMethodDescriptionfinal BackOff
Returns the back-off.final Sleeper
Returns the sleeper.boolean
handleIOException
(HttpRequest request, boolean supportsRetry) Invoked when anIOException
is thrown during an HTTP request.setSleeper
(Sleeper sleeper) Sets the sleeper.
-
Field Details
-
backOff
Back-off policy. -
sleeper
Sleeper.
-
-
Constructor Details
-
HttpBackOffIOExceptionHandler
Constructs a new instance from aBackOff
.- Parameters:
backOff
- back-off policy
-
-
Method Details
-
getBackOff
Returns the back-off. -
getSleeper
Returns the sleeper. -
setSleeper
Sets the sleeper.The default value is
Sleeper.DEFAULT
.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
handleIOException
Invoked when anIOException
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 toSleeper.sleep(long)
will be made.- Specified by:
handleIOException
in interfaceHttpIOExceptionHandler
- Parameters:
request
- request object that can be read from for context or modified before retrysupportsRetry
- whether there will actually be a retry if this handler returntrue
. 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).- Returns:
- whether or not this handler has made a change that will require the request to be re-sent.
- Throws:
IOException
-