On Mon, 2012-12-03 at 15:42 -0800, Jaikit Savla wrote:
> Hi Folks,
> 
> I am using PoolingClientConnectionManager and wanted to make sure I am not 
> leaking connections. I read Oleg's comment here ( 
> http://www.mail-archive.com/[email protected]/msg06061.html)
> 
> My question is:
> HttpGet httpGet = new HttpGet("http://targethost/stuff";;;);
> HttpResponse response = httpclient.execute(httpGet);
> try { HttpEntity entity = response1.getEntity(); // do something useful with 
> the response body // and manually ensure it is fully consumed
> } finally { EntityUtils.consume(response.getEntity());
> }
> 
> Will these also release connection ? (since documentation for 
> EntityUtils.consume does not mention that)
> 

Yes, it will.

> question2:
> DefaultHttpClient httpclient = new DefaultHttpClient();
> HttpGet httpGet = new HttpGet("http://targethost/homepage";;;);
> HttpResponse response = httpclient.execute(httpGet);
> try { System.out.println(response1.getStatusLine()); HttpEntity entity = 
> response1.getEntity(); // do something useful with the response body
> } finally { httpGet.releaseConnection();
> }
> 
> Will above close the stream too ?
> 

No, it will not. That is, the #close method of the content stream will
not be called. However, all the resources associated with it will be
freed.

Oleg

> Thanks,
> Jaikit
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to