Class RetryException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.springframework.core.retry.RetryException
All Implemented Interfaces:
Serializable

public class RetryException extends Exception
Exception thrown when a RetryPolicy has been exhausted or interrupted.

A RetryException will typically contain the last exception thrown by the Retryable operation as the cause and any exceptions from previous attempts as suppressed exceptions.

However, if an InterruptedException is encountered while sleeping for the current BackOff duration, a RetryException will contain the InterruptedException as the cause and any exceptions from previous invocations of the Retryable operation as suppressed exceptions.

Since:
7.0
Author:
Mahmoud Ben Hassine, Juergen Hoeller, Sam Brannen
See Also:
  • Constructor Details

    • RetryException

      public RetryException(String message, Throwable cause)
      Create a new RetryException for the supplied message and cause.
      Parameters:
      message - the detail message
      cause - the last exception thrown by the Retryable operation, or an InterruptedException thrown while sleeping for the current BackOff duration
  • Method Details

    • getCause

      public final Throwable getCause()
      Get the last exception thrown by the Retryable operation, or an InterruptedException thrown while sleeping for the current BackOff duration.
      Overrides:
      getCause in class Throwable
    • getRetryCount

      public int getRetryCount()
      Return the number of retry attempts, or 0 if no retry has been attempted after the initial invocation at all.