RetryRuleBuilder extends AbstractRuleBuilder { @Override public RetryRuleBuilder onException(Class<? extends Throwable> exception) { return (RetryRuleBuilder) super.onException(exception); } RetryRuleBuilder(BiPredicate<? super ClientRequestContext, ? super RequestHeaders> requestHeadersFilter); RetryRule thenBackoff(); RetryRule thenBackoff(Backoff backoff); RetryRule thenNoRetry(); @Override RetryRuleBuilder onResponseHeaders(
            BiPredicate<? super ClientRequestContext, ? super ResponseHeaders> responseHeadersFilter); @Override RetryRuleBuilder onResponseTrailers(
            BiPredicate<? super ClientRequestContext, ? super HttpHeaders> responseTrailersFilter); @Override RetryRuleBuilder onStatusClass(HttpStatusClass... statusClasses); @Override RetryRuleBuilder onStatusClass(Iterable<HttpStatusClass> statusClasses); @Override RetryRuleBuilder onServerErrorStatus(); @Override RetryRuleBuilder onStatus(HttpStatus... statuses); @Override RetryRuleBuilder onStatus(Iterable<HttpStatus> statuses); @Override RetryRuleBuilder onStatus(
            BiPredicate<? super ClientRequestContext, ? super HttpStatus> statusFilter); @Override RetryRuleBuilder onException(Class<? extends Throwable> exception); @Override RetryRuleBuilder onException(
            BiPredicate<? super ClientRequestContext, ? super Throwable> exceptionFilter); @Override RetryRuleBuilder onException(); @Override RetryRuleBuilder onUnprocessed();  }
@Test void onException() { final ClientRequestContext ctx = ClientRequestContext.of(HttpRequest.of(HttpMethod.GET, "/")); final Backoff backoff1 = Backoff.fixed(1000); final Backoff backoff2 = Backoff.fixed(2000); final RetryRule rule = RetryRule.of(RetryRule.builder() .onException(ClosedSessionException.class) .thenBackoff(backoff1), RetryRule.builder() .onException((unused, obj) -> { return "/".equals(ctx.path()) && obj instanceof WriteTimeoutException; }) .thenBackoff(backoff2)); assertBackoff(rule.shouldRetry(ctx, ClosedSessionException.get())).isSameAs(backoff1); assertBackoff(rule.shouldRetry(ctx, new CompletionException(ClosedSessionException.get()))) .isSameAs(backoff1); assertBackoff(rule.shouldRetry(ctx, WriteTimeoutException.get())).isSameAs(backoff2); assertBackoff(rule.shouldRetry(ctx, ResponseTimeoutException.get())).isNull(); assertBackoff(rule.shouldRetry(ctx, null)).isNull(); }