Class Retry

java.lang.Object
org.eclipse.aether.named.support.Retry

public final class Retry extends Object
Retry helper: retries given Callable as long as it returns null (interpreted as "no answer yet") or given time passes. This helper implements similar semantics regarding caller threads as Lock.tryLock(long, TimeUnit) method does: blocks the caller thread until operation return non-null value within the given waiting time and the current thread has not been interrupted.
Since:
1.7.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <R> R
    retry(long time, TimeUnit unit, long sleepMillis, Callable<R> operation, Predicate<Exception> retryPredicate, R defaultResult)
    Retries for given amount of time (time, unit) the passed in operation, sleeping given sleepMills between retries.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
  • Constructor Details

    • Retry

      private Retry()
  • Method Details

    • retry

      public static <R> R retry(long time, TimeUnit unit, long sleepMillis, Callable<R> operation, Predicate<Exception> retryPredicate, R defaultResult) throws InterruptedException
      Retries for given amount of time (time, unit) the passed in operation, sleeping given sleepMills between retries. In case operation returns null, it is assumed "is not done yet" state, so retry will happen (if time barrier allows). If time barrier passes, and still null ("is not done yet") is returned from operation, the defaultResult is returned.
      Throws:
      InterruptedException