Github user agherardi commented on the issue:
https://github.com/apache/httpcomponents-core/pull/56
My HTTP stack consists of Jersey https://github.com/jersey/jersey with the
Apache httpclient connector and the JacksonJsonProvider. I'm using the stack to
talk to a REST-ful server that returns JSON responses, and have Jersey +
JacksonJsonProvider automatically deserialize JSON responses to Java POJOs. The
approach is similar to the one described here
https://dennis-xlc.gitbooks.io/restful-java-with-jax-rs-2-0-en/cn/part1/chapter8/building_and_invoking_requests.html
While testing, I noticed that HTTP and HTTPS connections are not reused -
i.e., the stack opens and closes the HTTP/HTTPS connection for every REST call.
The underlying problem is that the Jersey httpclient connector closes the
CloseableHttpResponse BEFORE closing the response's content input stream.
I can think of a couple of ways to solve this issue. One is to reverse the
order in which the Jersey connector closes things - i,e,, first close the input
stream, then close the CloseableHttpResponse. I have a merge request out to the
Jersey maintainers https://github.com/jersey/jersey/pull/3752 for that.
The other possibility is to modify httpclient along the lines described in
this merge request. The idea is to make EofSensorInputStream#checkEOF more
proactive in detecting when a response has been consumed and release the
connection to the pool without waiting for a close().
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]