Class HttpBackOffIOExceptionHandler (1.42.2)

Stay organized with collections Save and categorize content based on your preferences.
public class HttpBackOffIOExceptionHandler implements 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

Inheritance

java.lang.Object > HttpBackOffIOExceptionHandler

Constructors

HttpBackOffIOExceptionHandler(BackOff backOff)

public HttpBackOffIOExceptionHandler(BackOff backOff)

Constructs a new instance from a BackOff.

Parameter
NameDescription
backOffBackOff

back-off policy

Methods

getBackOff()

public final BackOff getBackOff()

Returns the back-off.

Returns
TypeDescription
BackOff

getSleeper()

public final Sleeper getSleeper()

Returns the sleeper.

Returns
TypeDescription
Sleeper

handleIOException(HttpRequest request, boolean supportsRetry)

public boolean handleIOException(HttpRequest request, boolean supportsRetry)

Invoked when an 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#sleep(long) will be made.

Parameters
NameDescription
requestHttpRequest
supportsRetryboolean
Returns
TypeDescription
boolean
Exceptions
TypeDescription
IOException

setSleeper(Sleeper sleeper)

public HttpBackOffIOExceptionHandler setSleeper(Sleeper sleeper)

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.

Parameter
NameDescription
sleeperSleeper
Returns
TypeDescription
HttpBackOffIOExceptionHandler