Package io.atlassian.fugue.retry
Class RetryTask
- java.lang.Object
-
- io.atlassian.fugue.retry.RetryTask
-
- All Implemented Interfaces:
java.lang.Runnable
public class RetryTask extends java.lang.Object implements java.lang.RunnableA Runnable which wraps the apply method of another Runnable and attempts it a fixed number of times. This class can be used when a task is known to be prone to occasional failure and other workarounds are not known.
-
-
Field Summary
Fields Modifier and Type Field Description private RetrySupplier<?>retrySupplier
-
Constructor Summary
Constructors Constructor Description RetryTask(java.lang.Runnable task, int tries)An instance that does nothing before retrying and ignores exceptions that occur.RetryTask(java.lang.Runnable task, int tries, ExceptionHandler handler)An instance that does nothing before retrying.RetryTask(java.lang.Runnable task, int tries, ExceptionHandler handler, java.lang.Runnable beforeRetry)Constructor for RetryTask.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrun()Attempt to run the wrapped Runnable tries number of times.
-
-
-
Field Detail
-
retrySupplier
private RetrySupplier<?> retrySupplier
-
-
Constructor Detail
-
RetryTask
public RetryTask(java.lang.Runnable task, int tries)An instance that does nothing before retrying and ignores exceptions that occur.- Parameters:
task- to run, must not be nulltries- number of times to attempt to run task, must be posititve
-
RetryTask
public RetryTask(java.lang.Runnable task, int tries, ExceptionHandler handler)An instance that does nothing before retrying.- Parameters:
task- to run, must not be nulltries- number of times to attempt to run task, must be positivehandler- reacts to exceptions thrown by the wrapped task, must not be null
-
RetryTask
public RetryTask(java.lang.Runnable task, int tries, ExceptionHandler handler, java.lang.Runnable beforeRetry)Constructor for RetryTask.
- Parameters:
task- to run, must not be nulltries- number of times to attempt to run task, must be positivehandler- reacts to exceptions thrown by the wrapped task, must not be nullbeforeRetry- runs before each retry, must not be null
-
-
Method Detail
-
run
public void run()
Attempt to run the wrapped Runnable tries number of times. Any exceptions thrown will be ignored until the number of attempts is reached. If the number of attempts is reached without success, the most recent exception to be thrown will be rethrown.- Specified by:
runin interfacejava.lang.Runnable
-
-