Package com.google.api.client.http
Interface HttpIOExceptionHandler
-
- All Known Implementing Classes:
HttpBackOffIOExceptionHandler
@Beta public interface HttpIOExceptionHandler
Beta
Handles anIOException
in an HTTP request.For example, this might be used to handle an
IOException
withBackOff
policy.public static class HttpBackOffIOExceptionHandler implements HttpIOExceptionHandler { BackOff backOff; Sleeper sleeper; public boolean handle(HttpRequest request, boolean supportsRetry) throws IOException { if (!supportsRetry) { return false; } try { return BackOffUtils.next(sleeper, backOff); } catch (InterruptedException exception) { return false; } } }
- Since:
- 1.15
- Author:
- Eyal Peled
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
handleIOException(HttpRequest request, boolean supportsRetry)
Invoked when anIOException
is thrown during an HTTP request.
-
-
-
Method Detail
-
handleIOException
boolean handleIOException(HttpRequest request, boolean supportsRetry) throws IOException
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.- 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
-
-