Forum Discussion
gg38660
14 years agoNew Contributor
I have a suggestion :
in HttpClientRequestTransport.sendRequest() function
i saw in finally bloc code :
a look at releasConnection code let's me think that the first call only close responseStream but not close the socket.
the only method to ensure that the connection is closed is to call the private ensureConnectionRelease function.
A very simple work around is to call twice httpMethod.releaseConnection() in the finaly bloc code => the first call close the responseStream and the second call close responseConnection.
It's look like a bug in apache HttpMethodBase class isn't it?
in HttpClientRequestTransport.sendRequest() function
i saw in finally bloc code :
if( httpMethod != null )
{
httpMethod.releaseConnection();
}
a look at releasConnection code let's me think that the first call only close responseStream but not close the socket.
the only method to ensure that the connection is closed is to call the private ensureConnectionRelease function.
A very simple work around is to call twice httpMethod.releaseConnection() in the finaly bloc code => the first call close the responseStream and the second call close responseConnection.
It's look like a bug in apache HttpMethodBase class isn't it?
public void releaseConnection() {
1315
1316 if (responseStream != null) {
1317 try {
1318 // FYI - this may indirectly invoke responseBodyConsumed.
1319 responseStream.close();
1320 } catch (IOException e) {
1321 // the connection may not have been released, let's make sure
1322 ensureConnectionRelease();
1323 }
1324 } else {
1325 // Make sure the connection has been released. If the response
1326 // stream has not been set, this is the only way to release the
1327 // connection.
1328 ensureConnectionRelease();
1329 }
1330 }
private void ensureConnectionRelease() {
2771 if (responseConnection != null) {
2772 responseConnection.releaseConnection();
2773 responseConnection = null;
2774 }
2775 }