RetryRuleBuilder extends AbstractRuleBuilder { @Override public RetryRuleBuilder onStatus(HttpStatus... statuses) { return (RetryRuleBuilder) super.onStatus(statuses); } 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 onStatus() { final Backoff backoff500 = Backoff.fixed(1000); final Backoff backoff502 = Backoff.fixed(1000); final RetryRule rule = RetryRule.builder() .onStatus(HttpStatus.INTERNAL_SERVER_ERROR) .thenBackoff(backoff500) .orElse(RetryRule.builder() .onStatus((unused, status) -> HttpStatus.BAD_GATEWAY.equals(status)) .thenBackoff(backoff502)); final ClientRequestContext ctx1 = ClientRequestContext.of(HttpRequest.of(HttpMethod.GET, "/")); ctx1.logBuilder().responseHeaders(ResponseHeaders.of(HttpStatus.INTERNAL_SERVER_ERROR)); assertBackoff(rule.shouldRetry(ctx1, null)).isSameAs(backoff500); final ClientRequestContext ctx2 = ClientRequestContext.of(HttpRequest.of(HttpMethod.GET, "/")); ctx2.logBuilder().responseHeaders(ResponseHeaders.of(HttpStatus.BAD_GATEWAY)); assertBackoff(rule.shouldRetry(ctx2, null)).isSameAs(backoff502); final ClientRequestContext ctx3 = ClientRequestContext.of(HttpRequest.of(HttpMethod.GET, "/")); ctx3.logBuilder().responseHeaders(ResponseHeaders.of(HttpStatus.GATEWAY_TIMEOUT)); assertBackoff(rule.shouldRetry(ctx3, null)).isNull(); }