@Test void canBeOverridden() throws Exception { RetryStrategy customStrategy = new BestEffortRetryStrategy() { @Override public CompletableFuture<RetryAction> shouldRetry(Request<? extends Response> request, RetryReason reason) { if (reason == RetryReason.ENDPOINT_CIRCUIT_OPEN) { return CompletableFuture.completedFuture(RetryAction.noRetry()); } return super.shouldRetry(request, reason); } }; RetryAction retryAction = customStrategy.shouldRetry(null, RetryReason.ENDPOINT_CIRCUIT_OPEN).get(); assertEquals(RetryAction.noRetry(), retryAction); }
@Override public CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason) { if (request.idempotent() || reason.allowsNonIdempotentRetry()) { RequestContext ctx = request.context(); return CompletableFuture.completedFuture(RetryAction.withDuration( backoff.apply(new RetryStrategyIterationContext(ctx.retryAttempts(), ctx.lastRetryDuration())).delay() )); } return CompletableFuture.completedFuture(RetryAction.noRetry()); }
BestEffortRetryStrategy implements RetryStrategy { @Override public CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason) { if (request.idempotent() || reason.allowsNonIdempotentRetry()) { RequestContext ctx = request.context(); return CompletableFuture.completedFuture(RetryAction.withDuration( backoff.apply(new RetryStrategyIterationContext(ctx.retryAttempts(), ctx.lastRetryDuration())).delay() )); } return CompletableFuture.completedFuture(RetryAction.noRetry()); } }
BestEffortRetryStrategy implements RetryStrategy { @Override public CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason) { if (request.idempotent() || reason.allowsNonIdempotentRetry()) { RequestContext ctx = request.context(); return CompletableFuture.completedFuture(RetryAction.withDuration( backoff.apply(new RetryStrategyIterationContext(ctx.retryAttempts(), ctx.lastRetryDuration())).delay() )); } return CompletableFuture.completedFuture(RetryAction.noRetry()); } protected  BestEffortRetryStrategy(); protected  BestEffortRetryStrategy(final Backoff backoff); }
BestEffortRetryStrategy implements RetryStrategy { @Override public CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason) { if (request.idempotent() || reason.allowsNonIdempotentRetry()) { RequestContext ctx = request.context(); return CompletableFuture.completedFuture(RetryAction.withDuration( backoff.apply(new RetryStrategyIterationContext(ctx.retryAttempts(), ctx.lastRetryDuration())).delay() )); } return CompletableFuture.completedFuture(RetryAction.noRetry()); } protected  BestEffortRetryStrategy(); protected  BestEffortRetryStrategy(final Backoff backoff); static BestEffortRetryStrategy withExponentialBackoff(final Duration lower, final Duration upper,
                                                               final int factor); @Override CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason); @Override String toString(); }
BestEffortRetryStrategy implements RetryStrategy { @Override public CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason) { if (request.idempotent() || reason.allowsNonIdempotentRetry()) { RequestContext ctx = request.context(); return CompletableFuture.completedFuture(RetryAction.withDuration( backoff.apply(new RetryStrategyIterationContext(ctx.retryAttempts(), ctx.lastRetryDuration())).delay() )); } return CompletableFuture.completedFuture(RetryAction.noRetry()); } protected  BestEffortRetryStrategy(); protected  BestEffortRetryStrategy(final Backoff backoff); static BestEffortRetryStrategy withExponentialBackoff(final Duration lower, final Duration upper,
                                                               final int factor); @Override CompletableFuture<RetryAction> shouldRetry(final Request<? extends Response> request, final RetryReason reason); @Override String toString(); static final BestEffortRetryStrategy INSTANCE; }