Package com.nike.pdm.localstack.core
Class Retry
- java.lang.Object
- 
- com.nike.pdm.localstack.core.Retry
 
- 
 public final class Retry extends java.lang.ObjectWrapper function that retries, with exponential backoff, in the event of an exception.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceRetry.RetryableFunction<T>Function that adds retries with exponential backoff.
 - 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_MAX_RETRIES
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Texecute(Retry.RetryableFunction<T> fn)Executes the wrapped function with default maximum number of retries in the event of an exception.static <T> Texecute(Retry.RetryableFunction<T> fn, int maxRetries)Executes the wrapped function with the specified maximum number of retries in the event of an exception.static <T> Texecute(Retry.RetryableFunction<T> fn, int maxRetries, java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> expectedErrors)Executes the wrapped function, terminating immediately if one of the expected errors is encountered, otherwise the function will be retried up to the specified maximum number of retries.static <T> Texecute(Retry.RetryableFunction<T> fn, java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> expectedErrors)Executes the wrapped function, terminating immediately if one of the expected errors is encountered.
 
- 
- 
- 
Field Detail- 
DEFAULT_MAX_RETRIESpublic static final int DEFAULT_MAX_RETRIES - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
executepublic static <T> T execute(Retry.RetryableFunction<T> fn) Executes the wrapped function with default maximum number of retries in the event of an exception.- Type Parameters:
- T- return type of the wrapped function
- Parameters:
- fn- wrapped function to execute
- Returns:
- result of the wrapped function
 
 - 
executepublic static <T> T execute(Retry.RetryableFunction<T> fn, int maxRetries) Executes the wrapped function with the specified maximum number of retries in the event of an exception.- Type Parameters:
- T- return type of the wrapped function
- Parameters:
- fn- wrapped function to execute
- maxRetries- maximum number of times to retry the wrapped function in the event of an exception
- Returns:
- result of the wrapped function
 
 - 
executepublic static <T> T execute(Retry.RetryableFunction<T> fn, java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> expectedErrors) Executes the wrapped function, terminating immediately if one of the expected errors is encountered.- Type Parameters:
- T- return type of the wrapped function
- Parameters:
- fn- wrapped function to execute
- expectedErrors- a collection of errors that when encountered will cause the function to fail immediately without exhausting the maximum number of retries
- Returns:
- result of the wrapped function
 
 - 
executepublic static <T> T execute(Retry.RetryableFunction<T> fn, int maxRetries, java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> expectedErrors) Executes the wrapped function, terminating immediately if one of the expected errors is encountered, otherwise the function will be retried up to the specified maximum number of retries.- Type Parameters:
- T- return type of the wrapped function
- Parameters:
- fn- wrapped function to execute
- maxRetries- maximum number of times to retry the wrapped function in the event of an exception not specified in the expectedErrors
- expectedErrors- a collection of errors that when encountered will cause the function to fail immediately without exhausting the maximum number of retries
- Returns:
- result of the wrapped function
 
 
- 
 
-