Package org.eclipse.aether.named.support
Class Retry
- java.lang.Object
-
- org.eclipse.aether.named.support.Retry
-
public final class Retry extends java.lang.Object
Retry helper: retries givenCallableas long as it returnsnull(interpreted as "no answer yet") or given time passes. This helper implements similar semantics regarding caller threads asLock.tryLock(long, TimeUnit)method does: blocks the caller thread until operation return non-nullvalue within the given waiting time and the current thread has not been interrupted.- Since:
- 1.7.3
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <R> Rretry(long time, java.util.concurrent.TimeUnit unit, long sleepMillis, java.util.concurrent.Callable<R> operation, java.util.function.Predicate<java.lang.Exception> retryPredicate, R defaultResult)Retries for given amount of time (time, unit) the passed in operation, sleeping givensleepMillsbetween retries.
-
-
-
Method Detail
-
retry
public static <R> R retry(long time, java.util.concurrent.TimeUnit unit, long sleepMillis, java.util.concurrent.Callable<R> operation, java.util.function.Predicate<java.lang.Exception> retryPredicate, R defaultResult) throws java.lang.InterruptedException
Retries for given amount of time (time, unit) the passed in operation, sleeping givensleepMillsbetween retries. In case operation returnsnull, it is assumed "is not done yet" state, so retry will happen (if time barrier allows). If time barrier passes, and stillnull("is not done yet") is returned from operation, thedefaultResultis returned.- Throws:
java.lang.InterruptedException
-
-