hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r813104 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
Date Wed, 09 Sep 2009 20:31:06 GMT
Author: olegk
Date: Wed Sep  9 20:31:05 2009
New Revision: 813104

URL: http://svn.apache.org/viewvc?rev=813104&view=rev
Log:
HTTPCLIENT-875: DefaultClientConnectionOperator#openConnection doesn't update the connection
state if the connection socket changed after the call to SocketFactory#connectSocket()

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=813104&r1=813103&r2=813104&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Wed Sep  9 20:31:05 2009
@@ -1,6 +1,11 @@
 Changes since 4.0
 -------------------
 
+* [HTTPCLIENT-875] DefaultClientConnectionOperator#openConnection doesn't 
+  update the connection state if the connection socket changed after 
+  the call to SocketFactory#connectSocket().
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-834] Transparent content encoding support.
   Contributed by James Abley <james.abley at gmail.com>
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java?rev=813104&r1=813103&r2=813104&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/OperatedClientConnection.java
Wed Sep  9 20:31:05 2009
@@ -82,20 +82,25 @@
 
     /**
      * Signals that this connection is in the process of being open.
-     * <br/>
-     * By calling this method, you can provide the connection with
-     * the unconnected socket that will be connected before
-     * {@link #openCompleted} is called. This allows 
-     * the connection to close that socket if
+     * <p>
+     * By calling this method, the connection can be re-initialized
+     * with a new Socket instance before {@link #openCompleted} is called. 
+     * This enabled the connection to close that socket if
      * {@link org.apache.http.HttpConnection#shutdown shutdown}
-     * is called before it is open. Closing the unconnected socket
+     * is called before it is fully open. Closing an unconnected socket
      * will interrupt a thread that is blocked on the connect.
      * Otherwise, that thread will either time out on the connect,
      * or it returns successfully and then opens this connection
      * which was just shut down.
-     * <br/>
-     * You also must call {@link #openCompleted} in order to complete
-     * the process
+     * <p>
+     * This method can be called multiple times if the connection 
+     * is layered over another protocol. <b>Note:</b> This method 
+     * will <i>not</i> close the previously used socket. It is 
+     * the caller's responsibility to close that socket if it is 
+     * no longer required.
+     * <p>
+     * The caller must invoke {@link #openCompleted} in order to complete
+     * the process.
      *
      * @param sock      the unconnected socket which is about to
      *                  be connected.

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java?rev=813104&r1=813103&r2=813104&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
Wed Sep  9 20:31:05 2009
@@ -120,9 +120,13 @@
         conn.opening(sock, target);
 
         try {
-            sock = sf.connectSocket(sock, target.getHostName(),
+            Socket connsock = sf.connectSocket(sock, target.getHostName(),
                     schm.resolvePort(target.getPort()),
                     local, 0, params);
+            if (sock != connsock) {
+                sock = connsock;
+                conn.opening(sock, target);
+            }
         } catch (ConnectException ex) {
             throw new HttpHostConnectException(target, ex);
         }



Mime
View raw message