You must consume the HttpEntity in every case, even if there is an exception, 
or you will leak connections from your ConnectionManager's pool.

You can consume entities via:

* Calling any of the EntityUtils.* methods.
* Using a org.apache.http.impl.client.BasicResponseHandler (or any 
org.apache.http.client.ResponseHandler implementation that consumes the 
HttpEntity).
* Calling abort() on the HttpUriRequest in case of an exception.
See [1] for more information.

Do not call releaseConnection explicitly (unless you're implementing a 
ConnectionManager or working at low levels).  Doing so may conflict with any 
Keep-Alive strategies or connection persistence you might use.  See [2], 
section 2.8 for more information.

[1] 
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html
[2] http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

On Jan 30, 2012, at 10:33 AM, Mohit Anchlia wrote:

> HttpClient 4.1.2 - I am using Multithreaded connection manager. Do I
> need to explicitly call releaseConnection on this?
> 
> Also, after every http request I am calling
> EntityUtils.toByteArray(entity), would it release connection or is
> this the right way to release connection?
> 
> I am seeing some wierd behaviour and want to undersand this little more.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

Reply via email to