You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2009/02/14 18:01:38 UTC
svn commit: r744525 - in /httpcomponents/httpclient/trunk: ./
module-client/src/main/java/org/apache/http/conn/
module-client/src/main/java/org/apache/http/conn/scheme/
module-client/src/main/java/org/apache/http/conn/ssl/
Author: olegk
Date: Sat Feb 14 17:01:38 2009
New Revision: 744525
URL: http://svn.apache.org/viewvc?rev=744525&view=rev
Log:
HTTPCLIENT-822: Default socket factories to re-throw SocketTimeoutException as ConnectTimeoutException in case of connect failure due to time out
Modified:
httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java
httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=744525&r1=744524&r2=744525&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Sat Feb 14 17:01:38 2009
@@ -1,3 +1,14 @@
+Changes since 4.0 beta 2
+-------------------
+
+* [HTTPCLIENT-822] Default socket factories to rethrow SocketTimeoutException as
+ ConnectTimeoutException in case of connect failure due to a time out.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* [HTTPCLIENT-813] Fixed default port resolution. Invalid ports no longer
+ get replaced with the default port value.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
Release 4.0 beta 2
-------------------
@@ -9,10 +20,6 @@
All upstream projects are strongly encouraged to upgrade.
-* [HTTPCLIENT-813] Fixed default port resolution. Invalid ports no longer
- get replaced with the default port value.
- Contributed by Oleg Kalnichevski <olegk at apache.org>
-
* Fixed NPE in DefaultRequestDirector thrown when retrying a failed
request over a proxied connection.
Contributed by Oleg Kalnichevski <olegk at apache.org>
Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java?rev=744525&r1=744524&r2=744525&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java Sat Feb 14 17:01:38 2009
@@ -41,7 +41,6 @@
import java.util.List;
import java.util.Arrays;
-import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.SocketFactory;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
@@ -131,12 +130,12 @@
Collections.shuffle(addresses);
IOException lastEx = null;
- for (InetAddress address: addresses) {
+ for (InetAddress remoteAddress: addresses) {
try {
- sock.connect(new InetSocketAddress(address, port), timeout);
+ sock.connect(new InetSocketAddress(remoteAddress, port), timeout);
break;
} catch (SocketTimeoutException ex) {
- throw ex;
+ throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
} catch (IOException ex) {
// create new socket
sock = new Socket();
@@ -185,28 +184,4 @@
} // isSecure
-
- /**
- * Compares this factory with an object.
- * There is only one instance of this class.
- *
- * @param obj the object to compare with
- *
- * @return iff the argument is this object
- */
- @Override
- public boolean equals(Object obj) {
- return (obj == this);
- }
-
- /**
- * Obtains a hash code for this object.
- * All instances of this class have the same hash code.
- * There is only one instance of this class.
- */
- @Override
- public int hashCode() {
- return PlainSocketFactory.class.hashCode();
- }
-
}
Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java?rev=744525&r1=744524&r2=744525&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java Sat Feb 14 17:01:38 2009
@@ -35,7 +35,9 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketTimeoutException;
+import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
@@ -115,9 +117,11 @@
} else {
remoteAddress = new InetSocketAddress(host, port);
}
-
- sock.connect(remoteAddress, timeout);
-
+ try {
+ sock.connect(remoteAddress, timeout);
+ } catch (SocketTimeoutException ex) {
+ throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
+ }
return sock;
} // connectSocket
Modified: httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java?rev=744525&r1=744524&r2=744525&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java Sat Feb 14 17:01:38 2009
@@ -31,6 +31,7 @@
package org.apache.http.conn.ssl;
+import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.scheme.HostNameResolver;
import org.apache.http.conn.scheme.LayeredSocketFactory;
import org.apache.http.params.HttpConnectionParams;
@@ -47,6 +48,7 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
@@ -318,9 +320,11 @@
} else {
remoteAddress = new InetSocketAddress(host, port);
}
-
- sslsock.connect(remoteAddress, connTimeout);
-
+ try {
+ sock.connect(remoteAddress, connTimeout);
+ } catch (SocketTimeoutException ex) {
+ throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
+ }
sslsock.setSoTimeout(soTimeout);
try {
hostnameVerifier.verify(host, sslsock);