Class RetryUtils


  • public class RetryUtils
    extends Object
    Since:
    2025.0
    • Method Detail

      • exponentialBackoff

        public static <T> T exponentialBackoff​(Supplier<T> supplier,
                                               int tryCount,
                                               Duration timeSlot,
                                               Duration threshold)
        Tries at most tryCount times to return the result of the given supplier, if not null. The waiting time between each try is computed with an exponential backoff algorithm based on the given timeSlot duration.

        If threshold is not null, then the waiting time doesn't exceed the threshold duration: when the waiting time reaches threshold, it is reset to timeSlot.

        Throws:
        RuntimeException - if the retry count was exceeded