Merge "Allow HttpEngine to retry connections on timeout / interruption."
diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/ConnectionSpecSelector.java b/okhttp/src/main/java/com/squareup/okhttp/internal/ConnectionSpecSelector.java
index dabe8b2..ac9de11 100644
--- a/okhttp/src/main/java/com/squareup/okhttp/internal/ConnectionSpecSelector.java
+++ b/okhttp/src/main/java/com/squareup/okhttp/internal/ConnectionSpecSelector.java
@@ -99,6 +99,12 @@
}
// If there was an interruption or timeout, don't recover.
+ //
+ // NOTE: This code (unlike the rest of this method) is not shared with HttpEngine.
+ // In HttpEngine, we would like to retry if we see an interruption or timeout because
+ // we might potentially be connecting to a different address family (IPV4 vs IPV6, say).
+ // That consideration is not relevant here, since the SocketConnector will always connect
+ // via the same Route even if the connection failed.
if (e instanceof InterruptedIOException) {
return false;
}
diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java b/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java
index 0fdce80..0b6af86 100644
--- a/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java
+++ b/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java
@@ -449,11 +449,6 @@
return false;
}
- // If there was an interruption or timeout, don't recover.
- if (ioe instanceof InterruptedIOException) {
- return false;
- }
-
// Look for known client-side or negotiation errors that are unlikely to be fixed by trying
// again with a different route.
if (ioe instanceof SSLHandshakeException) {