Class RetryTask

    • 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
      void run()
      Attempt to run the wrapped Runnable tries number of times.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 null
        tries - 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 null
        tries - number of times to attempt to run task, must be positive
        handler - 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 null
        tries - number of times to attempt to run task, must be positive
        handler - reacts to exceptions thrown by the wrapped task, must not be null
        beforeRetry - 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:
        run in interface java.lang.Runnable