Interface RetryInterceptor.Context<T>
- Enclosing class:
RetryInterceptor
public static interface RetryInterceptor.Context<T>
Context for deciding whether an HTTP call should be retried.
-
Method Summary
Modifier and TypeMethodDescriptiondeadline()Returns anOptionalspecifying the deadline for retrying, specified according toRetryInterceptor.Builder.timeout(Duration).Returns the resulting exception.static <T> RetryInterceptor.Context<T> of(HttpRequest request, @Nullable HttpResponse<T> response, @Nullable Throwable exception, int retryCount) Creates a new retry context based on the given state.static <T> RetryInterceptor.Context<T> of(HttpRequest request, @Nullable HttpResponse<T> response, @Nullable Throwable exception, int retryCount, @Nullable Instant deadline) Creates a new retry context based on the given state.request()Returns the last-sent request.response()Returns the resulting response.intReturns the number of times the request has been retried.
-
Method Details
-
request
HttpRequest request()Returns the last-sent request. Note that this might be different from therequestof this context's response (e.g. redirects). -
response
Optional<HttpResponse<T>> response()Returns the resulting response. Exactly one ofresponse()orexception()is non-null. -
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
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(HttpRequest request, @Nullable HttpResponse<T> response, @Nullable Throwable exception, int retryCount) Creates a new retry context based on the given state.- Throws:
IllegalArgumentException- if it is not the case that exactly one ofresponseorexceptionis non-null, or ifretryCountis negative
-
of
static <T> RetryInterceptor.Context<T> of(HttpRequest request, @Nullable HttpResponse<T> response, @Nullable Throwable exception, int retryCount, @Nullable Instant deadline) Creates a new retry context based on the given state.- Throws:
IllegalArgumentException- if it is not the case that exactly one ofresponseorexceptionis non-null, or ifretryCountis negative
-