Releases: kasapdev/java-retry
Releases · kasapdev/java-retry
Release list
v1.3.0
Added
Retry.withMaxDelay(Duration)- caps every backoff delay (applied after the
multiplier and jitter). Without a cap the delay grows unboundedly and, for a
large multiplier or many attempts,multiplier^noverflows to an endless
wait; the cap keeps waits bounded.Retry.onRetry(RetryListener)and the newRetryListenerfunctional
interface - called right before each retry with the 1-based failed attempt
number, its failure and the delay about to be waited. Works for both
executeandexecuteAsync; not called after the final attempt or for
non-retryable failures. A listener that throws aborts retrying (propagated
byexecute, completes the future exceptionally forexecuteAsync).
v1.2.0
Added
Retry.executeAsync(Supplier<CompletableFuture<T>>): an async counterpart to the existingexecute(Callable<T>), for tasks that already return aCompletableFuture<T>.- Applies the exact same retry policy as the synchronous path — reuses the existing exception-type matching (
retryOn) and delay computation (backoff multiplier + jitter) logic rather than duplicating it. - Never blocks a thread while waiting between attempts: retries are scheduled via
CompletableFuture.delayedExecutor(...)instead ofThread.sleep. - Treats a synchronous throw from the supplier itself the same as an exceptionally-completed future, and unwraps
CompletionExceptionbefore the retryability check soretryOn-configured types match as they would on the sync path. - Returns a
CompletableFuture<T>that completes with the eventual result, or completes exceptionally once retries are exhausted or the failure isn't retryable.
- Applies the exact same retry policy as the synchronous path — reuses the existing exception-type matching (
- New README "Async Retry" section with a runnable example, plus an additional realistic example (a reused policy across multiple calls) in "Usage".
- New
RetryTestcoverage for the async path: eventual success after N failures with exact invocation-count assertions, immediate failure on a non-retryable exception, exhaustion aftermaxAttempts, first-try success, and a supplier that throws synchronously before returning a future — all using short (single-digit ms) configured backoff, no real multi-second waits.
Zero dependencies, pure Java 17, no build tool required — unchanged from prior releases.