Package org.nuxeo.common.utils
Class RetryUtils
java.lang.Object
org.nuxeo.common.utils.RetryUtils
- Since:
- 2025.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
exponentialBackoff
(Supplier<T> supplier, int tryCount, Duration timeSlot) static <T> T
exponentialBackoff
(Supplier<T> supplier, int tryCount, Duration timeSlot, Duration threshold) Tries at mosttryCount
times to return the result of the givensupplier
, if not null.
-
Method Details
-
exponentialBackoff
-
exponentialBackoff
public static <T> T exponentialBackoff(Supplier<T> supplier, int tryCount, Duration timeSlot, Duration threshold) Tries at mosttryCount
times to return the result of the givensupplier
, if not null. The waiting time between each try is computed with an exponential backoff algorithm based on the giventimeSlot
duration.If
threshold
is not null, then the waiting time doesn't exceed thethreshold
duration: when the waiting time reachesthreshold
, it is reset totimeSlot
.- Throws:
RuntimeException
- if the retry count was exceeded
-