@Test public void testDoesNotRetryWhenErrorNotRetryable() { String nonRetryable = "{\"error\":{\"code\":\"ReferencedResourceNotProvisioned\",\"message\":\"Not provisioned\"}}"; HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http: HttpResponse response = HttpResponse.builder().statusCode(429).payload(nonRetryable).build(); assertFalse(handler.shouldRetryRequest(command, response)); }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() != 429 || isRateLimitError(response)) { return false; } try { Error error = parseError.apply(response); logger.debug("processing error: %s", error); boolean isRetryable = RETRYABLE_ERROR_CODE.equals(error.details().code()); return isRetryable ? super.shouldRetryRequest(command, response) : false; } catch (Exception ex) { logger.warn("could not parse error. Request won't be retried: %s", ex.getMessage()); return false; } }
AzureRetryableErrorHandler extends BackoffLimitedRetryHandler { @Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() != 429 || isRateLimitError(response)) { return false; } try { Error error = parseError.apply(response); logger.debug("processing error: %s", error); boolean isRetryable = RETRYABLE_ERROR_CODE.equals(error.details().code()); return isRetryable ? super.shouldRetryRequest(command, response) : false; } catch (Exception ex) { logger.warn("could not parse error. Request won't be retried: %s", ex.getMessage()); return false; } } }
AzureRetryableErrorHandler extends BackoffLimitedRetryHandler { @Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() != 429 || isRateLimitError(response)) { return false; } try { Error error = parseError.apply(response); logger.debug("processing error: %s", error); boolean isRetryable = RETRYABLE_ERROR_CODE.equals(error.details().code()); return isRetryable ? super.shouldRetryRequest(command, response) : false; } catch (Exception ex) { logger.warn("could not parse error. Request won't be retried: %s", ex.getMessage()); return false; } } @Inject  AzureRetryableErrorHandler(ParseJson<Error> parseError); }
AzureRetryableErrorHandler extends BackoffLimitedRetryHandler { @Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() != 429 || isRateLimitError(response)) { return false; } try { Error error = parseError.apply(response); logger.debug("processing error: %s", error); boolean isRetryable = RETRYABLE_ERROR_CODE.equals(error.details().code()); return isRetryable ? super.shouldRetryRequest(command, response) : false; } catch (Exception ex) { logger.warn("could not parse error. Request won't be retried: %s", ex.getMessage()); return false; } } @Inject  AzureRetryableErrorHandler(ParseJson<Error> parseError); @Override boolean shouldRetryRequest(HttpCommand command, HttpResponse response); }
AzureRetryableErrorHandler extends BackoffLimitedRetryHandler { @Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() != 429 || isRateLimitError(response)) { return false; } try { Error error = parseError.apply(response); logger.debug("processing error: %s", error); boolean isRetryable = RETRYABLE_ERROR_CODE.equals(error.details().code()); return isRetryable ? super.shouldRetryRequest(command, response) : false; } catch (Exception ex) { logger.warn("could not parse error. Request won't be retried: %s", ex.getMessage()); return false; } } @Inject  AzureRetryableErrorHandler(ParseJson<Error> parseError); @Override boolean shouldRetryRequest(HttpCommand command, HttpResponse response);  }