HTTPCLIENT-875: DefaultClientConnectionOperator#openConnection doesn't update the connection state if the connection socket changed after the call to SocketFactory#connectSocket()

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@813104 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2009-09-09 20:31:05 +00:00
parent 71a76c6b22
commit 44ece542dc
3 changed files with 24 additions and 10 deletions

View File

@ -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>

View File

@ -82,20 +82,25 @@ public interface OperatedClientConnection extends HttpClientConnection, HttpInet
/**
* 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.

View File

@ -120,9 +120,13 @@ public class DefaultClientConnectionOperator implements ClientConnectionOperator
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);
}