Class HttpBackOffIOExceptionHandler
- java.lang.Object
-
- com.google.api.client.http.HttpBackOffIOExceptionHandler
-
- All Implemented Interfaces:
HttpIOExceptionHandler
@Beta public class HttpBackOffIOExceptionHandler extends java.lang.Object implements HttpIOExceptionHandler
Beta
HttpIOExceptionHandlerimplementation withBackOff.It is designed to work with only one
HttpRequestat a time. As a result you MUST create a new instance ofHttpBackOffIOExceptionHandlerwith a new instance ofBackOfffor each instance ofHttpRequest.Sample usage:
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff());
Note: Implementation doesn't call
BackOff.reset()at all, since it expects a newBackOffinstance.Implementation is not thread-safe
- Since:
- 1.15
-
-
Constructor Summary
Constructors Constructor Description HttpBackOffIOExceptionHandler(BackOff backOff)Constructs a new instance from aBackOff.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BackOffgetBackOff()Returns the back-off.SleepergetSleeper()Returns the sleeper.booleanhandleIOException(HttpRequest request, boolean supportsRetry)Invoked when anIOExceptionis thrown during an HTTP request.HttpBackOffIOExceptionHandlersetSleeper(Sleeper sleeper)Sets the sleeper.
-
-
-
Method Detail
-
getBackOff
public final BackOff getBackOff()
Returns the back-off.
-
getSleeper
public final Sleeper getSleeper()
Returns the sleeper.
-
setSleeper
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.
-
handleIOException
public boolean handleIOException(HttpRequest request, boolean supportsRetry) throws java.io.IOException
Invoked when anIOExceptionis 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
trueto 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:
handleIOExceptionin 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:
java.io.IOException
-
-