Class Retry<T>
java.lang.Object
com.atlassian.jira.user.anonymize.Retry<T>
- Type Parameters:
T
- return type
Captures exceptions thrown in a given closure and allows retrying.
-
Method Summary
Modifier and TypeMethodDescriptionRun the closure once and don't retryexecuteTimes
(int times) Run the closure once and then retry the given number of times.static <T> Retry<T>
static Retry<com.atlassian.jira.user.anonymize.Retry.NullReturn>
onException
(Consumer<Exception> exceptionHandler) Sets the handler function that will be called every time the closure throws an exception -- passing that exception as an argument -- even if there're retries left.Sets the the handler function that will be called after execution of the closure had failed and the number of retries is exhausted.Sets the function called after successful execution of the closure.
-
Method Details
-
from
-
from
-
onException
Sets the handler function that will be called every time the closure throws an exception -- passing that exception as an argument -- even if there're retries left. There can be only one handler of this type at one time. Any subsequent call to this function will override the previous value.- Parameters:
exceptionHandler
- handler function or null to remove the previous handler- Returns:
- a fresh object with new configuration
-
onFail
Sets the the handler function that will be called after execution of the closure had failed and the number of retries is exhausted. The argument passed to the handler is the last exception returned from the closure. There can be only one handler of this type at one time. Any subsequent call to this function will override the previous value.- Parameters:
failureHandler
- handler function or null to remove the previous handler- Returns:
- a fresh object with new configuration
-
onSuccess
Sets the function called after successful execution of the closure. Number of retries necessary to achieve success is passed as an argument. There can be only one handler of this type at one time. Any subsequent call to this function will override the previous value.- Parameters:
successHandler
- handler function or null to remove the previous handler- Returns:
- a fresh object with new configuration
-
rethrowOnFail
-
executeOnce
Run the closure once and don't retry- Returns:
- return value of the closure, null if there was an exception
-
executeTimes
Run the closure once and then retry the given number of times.- Parameters:
times
- number of retires. "0" causes the closure to be called only once- Returns:
- return value of the last call to the closure, null if all retires were unsuccessful
-