I have been using jersey 2.7 client version with HttpClient 4.3 for
connection pooling.
However, after upgrading to 2.23 (HttpClient to 4.5.2) I have noticed
that connections are explicitly closed by jersey client instead of
releasing them to connection pool. This is preventing connections from
re-use.
For instance, from 2.23 ApacheConnector.java
private static InputStream getInputStream(final CloseableHttpResponse
response) throws IOException {
final InputStream inputStream;
if (response.getEntity() == null) {
inputStream = new ByteArrayInputStream(new byte[0]);
} else {
final InputStream i = response.getEntity().getContent();
if (i.markSupported()) {
inputStream = i;
} else {
inputStream = new BufferedInputStream(i,
ReaderWriter.BUFFER_SIZE);
}
}
return new FilterInputStream(inputStream) {
@Override
public void close() throws IOException {
response.close();
super.close();
}
};
}
The "response.close()" from above snippet explicitly closing
"CloseableHttpClient" with "reuse" flag set to false.
I understand that above behavior has been added due to following issue.
https://java.net/jira/browse/JERSEY-2852
However, this will present performance related issues. Is there a way
that we can make connection closing via a property?
Thanks