I use Apache http client 4.1 and always close the response InputStream
(eg 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 explicitly 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( );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.