How to release connection with Apache http client property?
I use Apache http client 4.1 and always close the response InputStream
(e.g. by calling EntityUtils.consume(response.getEntity)
) after the HttpGet
execution.
Now I wonder whether the connection is properly released if the HttpGet
execution throws an exception. Should I release the connection 开发者_如何学Cexplicitly in this case?
Always close I/O objects in the finally
clause if you acquired them.
InputStrem input = acquireStream( );
try
{
useStream( input );
}
finally
{
input.close( );
}
精彩评论