Module methanol

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

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Optional<java.time.Instant> deadline()
      Returns an Optional specifying the deadline for retrying, specified according to RetryInterceptor.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.HttpRequest request()
      Returns the last-sent request.
      java.util.Optional<java.net.http.HttpResponse<T>> response()
      Returns the resulting response.
      int retryCount()
      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 the request of this context's response (e.g. redirects).
      • response

        java.util.Optional<java.net.http.HttpResponse<T>> response()
        Returns the resulting response. Exactly one of response() or exception() is non-null.
      • exception

        java.util.Optional<java.lang.Throwable> exception()
        Returns the resulting exception. Exactly one of response() or exception() 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 an Optional specifying the deadline for retrying, specified according to RetryInterceptor.Builder.timeout(Duration). If the given deadline is exceeded before a non-retryable response or exception is received, a HttpTimeoutException is 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 of response or exception is non-null, or if retryCount is 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 of response or exception is non-null, or if retryCount is negative