HttpClient 4.0.1 - how to release connection?
The recommended way, by Httpcomponents 4.1, is to close connection and release any underlying resources:
EntityUtils.consume(HttpEntity)
where HttpEntity
passed is a response entity.
This seems to work great :
if( response.getEntity() != null ) {
response.getEntity().consumeContent();
}//if
And don't forget to consume the entity even if you didn't open its content. For instance, you expect a HTTP_OK status from the response and don't get it, you still have to consume the entity !