RetryDeterminer { public abstract boolean shouldRetry(X e);  abstract boolean shouldRetry(X e); static RetryDeterminer<IOException> createRateLimitedRetryDeterminer(
      final ApiErrorExtractor errorExtractor); static final RetryDeterminer<Exception> DEFAULT; static final RetryDeterminer<IOException> SOCKET_ERRORS; static final RetryDeterminer<IOException> SERVER_ERRORS; static final RetryDeterminer<IOException> RATE_LIMIT_ERRORS; }
@Test public void defaultRetriesCorrectly() throws Exception { assertThat(RetryDeterminer.DEFAULT.shouldRetry(new SocketTimeoutException())).isTrue(); assertThat( RetryDeterminer.SOCKET_ERRORS.shouldRetry( new SSLException("test", new SocketException()))) .isTrue(); assertThat(RetryDeterminer.SOCKET_ERRORS.shouldRetry(new SSLException("invalid certificate"))) .isFalse(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(new IllegalArgumentException())).isFalse(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(new InterruptedException())).isFalse(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(makeHttpException(300))).isFalse(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(makeHttpException(504))).isTrue(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(makeHttpException(500))).isTrue(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(makeHttpException(599))).isTrue(); assertThat(RetryDeterminer.DEFAULT.shouldRetry(makeHttpException(499))).isFalse(); }
@Test public void socketRetriesCorrectly() throws IOException { assertThat(RetryDeterminer.SOCKET_ERRORS.shouldRetry(new SocketTimeoutException())).isTrue(); assertThat( RetryDeterminer.SOCKET_ERRORS.shouldRetry( new SSLException("test", new SocketException()))) .isTrue(); assertThat(RetryDeterminer.SOCKET_ERRORS.shouldRetry(new SSLException("invalid certificate"))) .isFalse(); assertThat(RetryDeterminer.SOCKET_ERRORS.shouldRetry(new IOException("Hey"))).isFalse(); assertThat(RetryDeterminer.SOCKET_ERRORS.shouldRetry(makeHttpException(300))).isFalse(); assertThat(RetryDeterminer.SOCKET_ERRORS.shouldRetry(makeHttpException(504))).isFalse(); }
@Test public void serverRetriesCorrectly() throws IOException { assertThat(RetryDeterminer.SERVER_ERRORS.shouldRetry(new SocketTimeoutException())).isFalse(); assertThat(RetryDeterminer.SERVER_ERRORS.shouldRetry(makeHttpException(300))).isFalse(); assertThat(RetryDeterminer.SERVER_ERRORS.shouldRetry(makeHttpException(504))).isTrue(); assertThat(RetryDeterminer.SERVER_ERRORS.shouldRetry(makeHttpException(500))).isTrue(); assertThat(RetryDeterminer.SERVER_ERRORS.shouldRetry(makeHttpException(599))).isTrue(); assertThat(RetryDeterminer.SERVER_ERRORS.shouldRetry(makeHttpException(499))).isFalse(); }