users@jersey.java.net

[Jersey] Re: Jersey 2.23 and connection closing

From: Komediant . <komediant_at_hotmail.com>
Date: Sun, 10 Jul 2016 15:49:47 +0000

unsubscribe

________________________________
Van: Rallavagu <rallavagu_at_gmail.com>
Verzonden: zaterdag 11 juni 2016 16:51:52
Aan: Thomas Meyer; users_at_jersey.java.net
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 <rallavagu_at_gmail.com>:
>> 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.
>