-
- Enclosing class:
- RetryInterceptor
public static interface RetryInterceptor.Context<T>Context for deciding whether an HTTP call should be retried.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Optional<java.time.Instant>deadline()Returns anOptionalspecifying the deadline for retrying, specified according toRetryInterceptor.Builder.timeout(Duration).java.util.Optional<java.lang.Throwable>exception()Returns the resulting exception.static <T> RetryInterceptor.Context<T>of(java.net.http.HttpRequest request, @Nullable java.net.http.HttpResponse<T> response, @Nullable java.lang.Throwable exception, int retryCount)Creates a new retry context based on the given state.static <T> RetryInterceptor.Context<T>of(java.net.http.HttpRequest request, @Nullable java.net.http.HttpResponse<T> response, @Nullable java.lang.Throwable exception, int retryCount, @Nullable java.time.Instant deadline)Creates a new retry context based on the given state.java.net.http.HttpRequestrequest()Returns the last-sent request.java.util.Optional<java.net.http.HttpResponse<T>>response()Returns the resulting response.intretryCount()Returns the number of times the request has been retried.
-
-
-
Method Detail
-
request
java.net.http.HttpRequest request()
Returns the last-sent request. Note that this might be different from therequestof this context's response (e.g. redirects).
-
response
java.util.Optional<java.net.http.HttpResponse<T>> response()
Returns the resulting response. Exactly one ofresponse()orexception()is non-null.
-
exception
java.util.Optional<java.lang.Throwable> exception()
Returns the resulting exception. Exactly one ofresponse()orexception()is non-null.
-
retryCount
int retryCount()
Returns the number of times the request has been retried.
-
deadline
java.util.Optional<java.time.Instant> deadline()
Returns anOptionalspecifying the deadline for retrying, specified according toRetryInterceptor.Builder.timeout(Duration). If the given deadline is exceeded before a non-retryable response or exception is received, aHttpTimeoutExceptionis thrown.
-
of
static <T> RetryInterceptor.Context<T> of(java.net.http.HttpRequest request, @Nullable java.net.http.HttpResponse<T> response, @Nullable java.lang.Throwable exception, int retryCount)
Creates a new retry context based on the given state.- Throws:
java.lang.IllegalArgumentException- if it is not the case that exactly one ofresponseorexceptionis non-null, or ifretryCountis negative
-
of
static <T> RetryInterceptor.Context<T> of(java.net.http.HttpRequest request, @Nullable java.net.http.HttpResponse<T> response, @Nullable java.lang.Throwable exception, int retryCount, @Nullable java.time.Instant deadline)
Creates a new retry context based on the given state.- Throws:
java.lang.IllegalArgumentException- if it is not the case that exactly one ofresponseorexceptionis non-null, or ifretryCountis negative
-
-