RetryInterceptor retries on SocketTimeoutException with no message (#4475)

This commit is contained in:
jack-berg 2022-05-18 08:11:28 -05:00 committed by GitHub
parent f592bf54e4
commit dbe9a8e0a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -102,7 +102,9 @@ public final class RetryInterceptor implements Interceptor {
return false;
}
String message = e.getMessage();
return message != null && message.toLowerCase().contains("connect timed out");
// Connect timeouts can produce SocketTimeoutExceptions with no message, or with "connect timed
// out"
return message == null || message.toLowerCase().contains("connect timed out");
}
// Visible for testing

View File

@ -195,7 +195,7 @@ class RetryInterceptorTest {
// Shouldn't retry on write timeouts, where error message is "timeout", or other IOException
assertThat(RetryInterceptor.isRetryableException(new SocketTimeoutException("timeout")))
.isFalse();
assertThat(RetryInterceptor.isRetryableException(new SocketTimeoutException())).isFalse();
assertThat(RetryInterceptor.isRetryableException(new SocketTimeoutException())).isTrue();
assertThat(RetryInterceptor.isRetryableException(new IOException("error"))).isFalse();
}