Class FailsafeCall


  • public final class FailsafeCall
    extends Object
    A Failsafe wrapped OkHttp Call. Supports synchronous and asynchronous executions, and cancellation.
    • Method Detail

      • cancel

        public void cancel()
        Cancels the call.
      • execute

        public okhttp3.Response execute()
                                 throws IOException
        Executes the call until a successful response is returned or the configured policies are exceeded. To avoid leaking resources callers should close the Response which in turn will close the underlying ResponseBody.
        Throws:
        IllegalStateException - if the call has already been executed
        IOException - if the request could not be executed due to cancellation, a connectivity problem, or timeout
        FailsafeException - if the execution fails with a checked Exception. Throwable.getCause() can be used to learn the underlying checked exception.
      • executeAsync

        public CompletableFuture<okhttp3.Response> executeAsync()
        Executes the call asynchronously until a successful result is returned or the configured policies are exceeded. To avoid leaking resources callers should close the Response which in turn will close the underlying ResponseBody.
      • isCancelled

        public boolean isCancelled()
        Returns whether the call has been cancelled.
      • isExecuted

        public boolean isExecuted()
        Returns whether the call has been executed.