Jersey 2.23 and connection closing

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Jersey 2.23 and connection closing

Rallavagu
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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey 2.23 and connection closing

Thomas Meyer
Am 10. Juni 2016 15:58:15 MESZ, schrieb Rallavagu <[hidden email]>:

>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

Hi,

I also did notice this problem and did open a bug in Java Jira for Jersey. But cannot find the bug is right now.

With kind regards
Thomas

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey 2.23 and connection closing

Thomas Meyer
In reply to this post by Rallavagu
Am 10. Juni 2016 15:58:15 MESZ, schrieb Rallavagu <[hidden email]>:

>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

Oh, and nobody did ever touch my bug report :-(

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey 2.23 and connection closing

Thomas Meyer
In reply to this post by Rallavagu
Am 10. Juni 2016 15:58:15 MESZ, schrieb Rallavagu <[hidden email]>:

>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

For the record. Issue is https://java.net/jira/browse/JERSEY-3086
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey 2.23 and connection closing

Rallavagu
In reply to this post by Thomas Meyer


On 6/10/16 8:26 AM, Thomas Meyer wrote:

> Am 10. Juni 2016 15:58:15 MESZ, schrieb Rallavagu <[hidden email]>:
>> 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
>
> Oh, and nobody did ever touch my bug report :-(

I see. Currently, I have downgraded to 2.22.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Jersey 2.23 and connection closing

Komediant .

unsubscribe


Van: Rallavagu <[hidden email]>
Verzonden: zaterdag 11 juni 2016 16:51:52
Aan: Thomas Meyer; [hidden email]
Onderwerp: [Jersey] Re: Jersey 2.23 and connection closing
 


On 6/10/16 8:26 AM, Thomas Meyer wrote:
> Am 10. Juni 2016 15:58:15 MESZ, schrieb Rallavagu <[hidden email]>:
>> 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
>
> Oh, and nobody did ever touch my bug report :-(

I see. Currently, I have downgraded to 2.22.
>
Loading...