You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Glyn Davies (JIRA)" <ji...@apache.org> on 2009/12/09 11:19:18 UTC
[jira] Issue Comment Edited: (HTTPCLIENT-875)
DefaultClientConnectionOperator doesn't update socket after call to
connectSocket(...)
[ https://issues.apache.org/jira/browse/HTTPCLIENT-875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788003#action_12788003 ]
Glyn Davies edited comment on HTTPCLIENT-875 at 12/9/09 10:18 AM:
------------------------------------------------------------------
I've found the following works:
{code}
conn.opening(sock, target);
conn.openCompleted(sf.isSecure(sock), params);
prepareSocket(sock, context, params);
conn.update(sock, target, sf.isSecure(sock), params);
{code}
1. openCompleted() requires the socket to be in a CLOSED state
2. prepareSocket() calls conn.bind() which marks the socket as OPEN
3. update() requires the socket in OPEN state
I do not think this is a viable true fix though, as I am sure it breaks a number of expectations.
(If Id not move opening() down, I see:
Caused by: java.net.SocketException: Socket is not connected
at java.net.Socket.getInputStream(Socket.java:770)
at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:123)
at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:99)
at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:165)
at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:162)
at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:123)
was (Author: glynd):
I've found the following works:
{code}
conn.openCompleted(sf.isSecure(sock), params);
prepareSocket(sock, context, params);
conn.update(sock, target, sf.isSecure(sock), params);
{code}
1. openCompleted() requires the socket to be in a CLOSED state
2. prepareSocket() calls conn.bind() which marks the socket as OPEN
3. update() requires the socket in OPEN state
> DefaultClientConnectionOperator doesn't update socket after call to connectSocket(...)
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-875
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-875
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient
> Affects Versions: 4.0 Beta 2, 4.0 Final
> Reporter: Connell Gauld
> Fix For: 4.1 Alpha1
>
> Attachments: HTTPCLIENT-875-2.patch, HTTPCLIENT-875.diff
>
>
> In the DefaultClientConnectionOperator function openConnection(...) it calls SocketFactory.connectSocket(...). The documentation for connectSocket(...) says that it returns:
> "the connected socket. The returned object may be different from
> the sock argument if this factory supports a layered protocol. "
> A quick peek at the source showed:
> In org.apache.http.impl.conn.DefaultClientConnectionOperator:
> 117 final SocketFactory sf = schm.getSocketFactory();
> 118
> 119 Socket sock = sf.createSocket();
> 120 conn.opening(sock, target);
> 121
> 122 try {
> 123 sock = sf.connectSocket(sock, target.getHostName(),
> 124 schm.resolvePort(target.getPort()),
> 125 local, 0, params);
> 126 } catch (ConnectException ex) {
> 127 throw new HttpHostConnectException(target, ex);
> 128 }
> 129 prepareSocket(sock, context, params);
> 130 conn.openCompleted(sf.isSecure(sock), params);
> So DefaultClientConnectionOperator never updates conn with the new version of sock that may have been returned from connectSocket(...).
> adding:
> 130 conn.openCompleted(sf.isSecure(sock), params);
> +++ 131 conn.update(sock, target, sf.isSecure(sock), params);
> appears to fix the issue.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org