On Wed, 2023-08-30 at 16:33 -0400, Brent Putman wrote: > > On 8/30/23 5:00 AM, Oleg Kalnichevski wrote: > > > > Again. It is called to make sure the entity has been fully consumed > > and > > the underlying connection the entity has been streaming its content > > from is fully re-usable. > > > So in the case of an unchecked RuntimeException or other Throwable, > that means that via the (lack of) handling in CloseableHttpClient, > the > connection possibly or probably can not be re-used, and that's > considered ok?
In case of an unchecked exception one simply does not want to re-use the connection. It is better to discard a perfectly valid connection rather than to re-use an invalid one. > And there isn't going to be any other resource leak? There ain't if the response gets properly closed. > > Just so we know, how does the connection pooling layer determine > re-usability when the returned connection is evaluated? Is it just > looking at the content InputStream and it's just simply: > closed=reusable, open=not-reusable? > The protocol layer needs to tell the connection management layer if the connection is considered valid and re-usable. > > > > One should always close HttpEntity. Internally HttpClien can > > optimize > > resource management operations and do only what is strictly > > necessary. > > > So then you would say that a properly written > HttpClientResponseHandler > should always call HttpEntity#close(), probably in a > try-with-resources? Correct. > And that the EntityUtils#consume call in the > CloseableHttpClient is really just there for the case of an > improperly > written handler that doesn't do that, and solely so that the > connection > can be reused? > Correct. It is an extra safety net. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org