@Test public void maxRetries() { WriteOptions options = WriteOptions.builder().maxRetries(5).build(); RetryAttempt retry = new RetryAttempt(new HttpException(errorResponse(429)), 1, options); Assertions.assertThat(retry.isRetry()).isTrue(); retry = new RetryAttempt(new HttpException(errorResponse(429)), 2, options); Assertions.assertThat(retry.isRetry()).isTrue(); retry = new RetryAttempt(new HttpException(errorResponse(429)), 3, options); Assertions.assertThat(retry.isRetry()).isTrue(); retry = new RetryAttempt(new HttpException(errorResponse(429)), 4, options); Assertions.assertThat(retry.isRetry()).isTrue(); retry = new RetryAttempt(new HttpException(errorResponse(429)), 5, options); Assertions.assertThat(retry.isRetry()).isTrue(); retry = new RetryAttempt(new HttpException(errorResponse(429)), 6, options); Assertions.assertThat(retry.isRetry()).isFalse(); }
boolean isRetry() { if (count > writeOptions.getMaxRetries()) { LOG.log(Level.WARNING, "Max write retries exceeded.", throwable); return false; } if (throwable instanceof HttpException) { HttpException he = (HttpException) throwable; return he.code() >= ABLE_TO_RETRY_ERROR; } if (throwable instanceof IOException) { if (throwable instanceof ProtocolException) { return false; } if (throwable instanceof InterruptedIOException) { return throwable instanceof SocketTimeoutException; } if (throwable instanceof SSLHandshakeException) { if (throwable.getCause() instanceof CertificateException) { return false; } } if (throwable instanceof SSLPeerUnverifiedException) { return false; } return true; } return false; }
RetryAttempt { boolean isRetry() { if (count > writeOptions.getMaxRetries()) { LOG.log(Level.WARNING, "Max write retries exceeded.", throwable); return false; } if (throwable instanceof HttpException) { HttpException he = (HttpException) throwable; return he.code() >= ABLE_TO_RETRY_ERROR; } if (throwable instanceof IOException) { if (throwable instanceof ProtocolException) { return false; } if (throwable instanceof InterruptedIOException) { return throwable instanceof SocketTimeoutException; } if (throwable instanceof SSLHandshakeException) { if (throwable.getCause() instanceof CertificateException) { return false; } } if (throwable instanceof SSLPeerUnverifiedException) { return false; } return true; } return false; } }
RetryAttempt { boolean isRetry() { if (count > writeOptions.getMaxRetries()) { LOG.log(Level.WARNING, "Max write retries exceeded.", throwable); return false; } if (throwable instanceof HttpException) { HttpException he = (HttpException) throwable; return he.code() >= ABLE_TO_RETRY_ERROR; } if (throwable instanceof IOException) { if (throwable instanceof ProtocolException) { return false; } if (throwable instanceof InterruptedIOException) { return throwable instanceof SocketTimeoutException; } if (throwable instanceof SSLHandshakeException) { if (throwable.getCause() instanceof CertificateException) { return false; } } if (throwable instanceof SSLPeerUnverifiedException) { return false; } return true; } return false; } RetryAttempt(final Throwable throwable, final int count, final WriteOptions writeOptions); }
RetryAttempt { boolean isRetry() { if (count > writeOptions.getMaxRetries()) { LOG.log(Level.WARNING, "Max write retries exceeded.", throwable); return false; } if (throwable instanceof HttpException) { HttpException he = (HttpException) throwable; return he.code() >= ABLE_TO_RETRY_ERROR; } if (throwable instanceof IOException) { if (throwable instanceof ProtocolException) { return false; } if (throwable instanceof InterruptedIOException) { return throwable instanceof SocketTimeoutException; } if (throwable instanceof SSLHandshakeException) { if (throwable.getCause() instanceof CertificateException) { return false; } } if (throwable instanceof SSLPeerUnverifiedException) { return false; } return true; } return false; } RetryAttempt(final Throwable throwable, final int count, final WriteOptions writeOptions);  }
RetryAttempt { boolean isRetry() { if (count > writeOptions.getMaxRetries()) { LOG.log(Level.WARNING, "Max write retries exceeded.", throwable); return false; } if (throwable instanceof HttpException) { HttpException he = (HttpException) throwable; return he.code() >= ABLE_TO_RETRY_ERROR; } if (throwable instanceof IOException) { if (throwable instanceof ProtocolException) { return false; } if (throwable instanceof InterruptedIOException) { return throwable instanceof SocketTimeoutException; } if (throwable instanceof SSLHandshakeException) { if (throwable.getCause() instanceof CertificateException) { return false; } } if (throwable instanceof SSLPeerUnverifiedException) { return false; } return true; } return false; } RetryAttempt(final Throwable throwable, final int count, final WriteOptions writeOptions);   }