Class Retryer.ForReturnValue<T>
- Enclosing class:
Retryer
-
Method Summary
Modifier and TypeMethodDescription<R extends T,
E extends Throwable>
CompletionStage<R> retry
(CheckedSupplier<? extends R, E> supplier, ScheduledExecutorService retryExecutor) Invokes and possibly retriessupplier
according to the retry strategies specified withuponReturn()
.<R extends T,
E extends Throwable>
CompletionStage<R> retryAsync
(CheckedSupplier<? extends CompletionStage<R>, E> asyncSupplier, ScheduledExecutorService retryExecutor) Invokes and possibly retriesasyncSupplier
according to the retry strategies specified withuponReturn()
.retryBlockingly
(CheckedSupplier<R, E> supplier) Invokes and possibly retriessupplier
according to the retry strategies specified withuponReturn()
.
-
Method Details
-
retryBlockingly
Invokes and possibly retriessupplier
according to the retry strategies specified withuponReturn()
.This method blocks while waiting to retry. If interrupted, retry is canceled.
If
supplier
fails despite retrying, the return value from the most recent invocation is returned.- Throws:
E
-
retry
public <R extends T,E extends Throwable> CompletionStage<R> retry(CheckedSupplier<? extends R, E> supplier, ScheduledExecutorService retryExecutor) Invokes and possibly retriessupplier
according to the retry strategies specified withuponReturn()
.The first invocation is done in the current thread. Unchecked exceptions thrown by
supplier
directly are propagated. This is to avoid hiding programming errors. Checked exceptions are reported through the returnedCompletionStage
so callers only need to deal with them in one place.Retries are scheduled and performed by
executor
.Canceling the returned future object will cancel currently pending retry attempts. Same if
supplier
throwsInterruptedException
.NOTE that if
executor.shutdownNow()
is called, the returnedCompletionStage
will never be done. -
retryAsync
public <R extends T,E extends Throwable> CompletionStage<R> retryAsync(CheckedSupplier<? extends CompletionStage<R>, E> asyncSupplier, ScheduledExecutorService retryExecutor) Invokes and possibly retriesasyncSupplier
according to the retry strategies specified withuponReturn()
.The first invocation is done in the current thread. Unchecked exceptions thrown by
asyncSupplier
directly are propagated. This is to avoid hiding programming errors. Checked exceptions are reported through the returnedCompletionStage
so callers only need to deal with them in one place.Retries are scheduled and performed by
executor
.Canceling the returned future object will cancel currently pending retry attempts. Same if
supplier
throwsInterruptedException
.NOTE that if
executor.shutdownNow()
is called, the returnedCompletionStage
will never be done.
-