开发者

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( );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜