Skip to content

v1.2.0

Choose a tag to compare

@kasapdev kasapdev released this 07 Sep 20:05
· 1 commit to main since this release

Added

  • Retry.executeAsync(Supplier<CompletableFuture<T>>): an async counterpart to the existing execute(Callable<T>), for tasks that already return a CompletableFuture<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 of Thread.sleep.
    • Treats a synchronous throw from the supplier itself the same as an exceptionally-completed future, and unwraps CompletionException before the retryability check so retryOn-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.
  • New README "Async Retry" section with a runnable example, plus an additional realistic example (a reused policy across multiple calls) in "Usage".
  • New RetryTest coverage for the async path: eventual success after N failures with exact invocation-count assertions, immediate failure on a non-retryable exception, exhaustion after maxAttempts, 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.