Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add UnknownHostException to set of retriable IOExceptions #2651

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.gson.stream.MalformedJsonException;
import java.io.IOException;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Set;
import javax.net.ssl.SSLException;

Expand Down Expand Up @@ -114,6 +115,8 @@ private RetryResult shouldRetryIOException(IOException ioException) {
SocketException se = (SocketException) cause;
return shouldRetryIOException(se);
}
} else if (ioException instanceof UnknownHostException && idempotent) {
return RetryResult.RETRY;
}
if (BaseServiceException.isRetryable(idempotent, ioException)) {
return RetryResult.RETRY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.IOException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -342,6 +343,7 @@ enum ThrowableCategory {
IO_EXCEPTION(new IOException("no retry")),
AUTH_RETRYABLE_TRUE(new RetryableException(true)),
AUTH_RETRYABLE_FALSE(new RetryableException(false)),
UNKNOWN_HOST_EXCEPTION(C.UNKNOWN_HOST_EXCEPTION),
;

private final Throwable throwable;
Expand Down Expand Up @@ -415,6 +417,8 @@ private static final class C {
private static final MalformedJsonException GSON_MALFORMED_EXCEPTION =
new MalformedJsonException("parse-exception");
private static final IOException IO_PREMATURE_EOF = new IOException("Premature EOF");
private static final UnknownHostException UNKNOWN_HOST_EXCEPTION =
new UnknownHostException("fake.fake");

private static HttpResponseException newHttpResponseException(
int httpStatusCode, String name) {
Expand Down Expand Up @@ -1065,6 +1069,16 @@ private static ImmutableList<Case> getAllCases() {
ThrowableCategory.AUTH_RETRYABLE_FALSE,
HandlerCategory.NONIDEMPOTENT,
ExpectRetry.NO,
Behavior.SAME),
new Case(
ThrowableCategory.UNKNOWN_HOST_EXCEPTION,
HandlerCategory.IDEMPOTENT,
ExpectRetry.YES,
Behavior.DEFAULT_MORE_PERMISSIBLE),
new Case(
ThrowableCategory.UNKNOWN_HOST_EXCEPTION,
HandlerCategory.NONIDEMPOTENT,
ExpectRetry.NO,
Behavior.SAME))
.build();
}
Expand Down
Loading