Annotation Interface Retry


@Target(METHOD) @Retention(RUNTIME) public @interface Retry
When annotated on a public/protected/package-private method in a Guice-constructed object this annotation will automatically retry if that method throws an exception
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    double
    The amount to multiply backoff time by for each failure
    long
    the backoff wait amount
    The backoff wait unit
    Class<? extends Throwable>[]
    The exception types which, if thrown, will bypass retry logic altogether
    Class<? extends Throwable>[]
    The core exception types which, if thrown, will bypass retry logic altogether.
    These are set to sensible defaults for regular Java code (Errors, IllegalArgumentExceptions and NullPointerExceptions)
    int[]
    If a RestException is thrown then if the HTTP Code is one of these values we don't retry.
    int
    The maximum number of attempts before the exception is thrown as normal
    Class<? extends Throwable>[]
    The exception types which, if thrown, will cause retry.
  • Element Details

    • backoffTime

      long backoffTime
      the backoff wait amount
      Returns:
      Default:
      1000L
    • backoffUnit

      TimeUnit backoffUnit
      The backoff wait unit
      Returns:
      Default:
      MILLISECONDS
    • backoffExponent

      double backoffExponent
      The amount to multiply backoff time by for each failure
      Returns:
      Default:
      2.0
    • maxAttempts

      int maxAttempts
      The maximum number of attempts before the exception is thrown as normal
      Returns:
      Default:
      3
    • on

      Class<? extends Throwable>[] on
      The exception types which, if thrown, will cause retry. Exceptions specified in this list will bypass any exceptions listed in exceptOn or exceptOnCore
      Returns:
      Default:
      {}
    • exceptOn

      Class<? extends Throwable>[] exceptOn
      The exception types which, if thrown, will bypass retry logic altogether
      Returns:
      Default:
      {}
    • exceptOnCore

      Class<? extends Throwable>[] exceptOnCore
      The core exception types which, if thrown, will bypass retry logic altogether.
      These are set to sensible defaults for regular Java code (Errors, IllegalArgumentExceptions and NullPointerExceptions)
      Returns:
      Default:
      {java.lang.Error.class, java.lang.IllegalArgumentException.class, java.lang.NullPointerException.class}
    • exceptOnRestExceptionCodes

      int[] exceptOnRestExceptionCodes
      If a RestException is thrown then if the HTTP Code is one of these values we don't retry. N.B. server-side we also consider an HTTP 303 redirection with a cause RestException having one of these codes
      Returns:
      Default:
      {403, 401, 400, 303}