[Jersey] Jersey 2.23 and connection closing

From: Rallavagu <>
Date: Fri, 10 Jun 2016 06:58:15 -0700

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

For instance, from 2.23

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,

         return new FilterInputStream(inputStream) {
             public void close() throws IOException {

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.

However, this will present performance related issues. Is there a way
that we can make connection closing via a property?