summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2011-09-12 19:26:42 -0400
committerJesse Wilson <jessewilson@google.com>2011-09-12 19:26:42 -0400
commitab691647a3d375ba17920e25ec8c8f9d6a80c5bf (patch)
treee898ffdbfa757d966acab076d35c8987cb39c2ae
parente2c43223891894d5985d3281700b8997b46e0e12 (diff)
downloadexternal_apache-http-ab691647a3d375ba17920e25ec8c8f9d6a80c5bf.zip
external_apache-http-ab691647a3d375ba17920e25ec8c8f9d6a80c5bf.tar.gz
external_apache-http-ab691647a3d375ba17920e25ec8c8f9d6a80c5bf.tar.bz2
Try the next address after any type of connection failure.
Previously we'd fail IPv4 if IPv6 failed with a EHOSTUNREACH error (which may be thrown as a SocketException or as a NoRouteToHostException, depending on the platform). Bug: http://b/5293809 Change-Id: Idca2e9bd561a23cff88b1399d45db65b96980148
-rw-r--r--src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java b/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
index fbc762d..d208853 100644
--- a/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
+++ b/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
@@ -36,6 +36,7 @@ import java.net.ConnectException;
import java.net.Socket;
import java.net.InetAddress;
+import java.net.SocketException;
import org.apache.http.HttpHost;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpConnectionParams;
@@ -173,10 +174,15 @@ public class DefaultClientConnectionOperator
conn.openCompleted(sf.isSecure(sock), params);
}
break;
- } catch (ConnectException ex) {
+ // BEGIN android-changed
+ // catch SocketException to cover any kind of connect failure
+ } catch (SocketException ex) {
if (i == addresses.length - 1) {
- throw new HttpHostConnectException(target, ex);
+ ConnectException cause = ex instanceof ConnectException
+ ? (ConnectException) ex : new ConnectException(ex.getMessage(), ex);
+ throw new HttpHostConnectException(target, cause);
}
+ // END android-changed
} catch (ConnectTimeoutException ex) {
if (i == addresses.length - 1) {
throw ex;
@@ -220,7 +226,7 @@ public class DefaultClientConnectionOperator
}
final LayeredSocketFactory lsf = (LayeredSocketFactory) schm.getSocketFactory();
- final Socket sock;
+ final Socket sock;
try {
sock = lsf.createSocket
(conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), true);