Allow HttpEngine to retry connections on timeout / interruption.
This reverts behaviour introduced in 60f5406dcc094d043 where HttpEngine
doesn't attempt to recover connections on timeout / interruption. This
new behaviour introduced regressions on some devices where we're handed
a mixture of IPV4 / IPV6 routes but where only one aspect of the network
(either IPV4 or 6) is functional.
bug: 22779586
Change-Id: Ibfb645f8d578257965c40a17c56dc7335f76c35b
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) {