users@jersey.java.net

Re: [Jersey] Thread waits indefinitely using Apache HTTP based Jersey Client[WAS]Re: Problem switching to ApacheHttpClient in Jersey 1.0.2

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 18 Feb 2009 10:27:35 +0100

On Feb 18, 2009, at 4:29 AM, Imran M Yousuf wrote:

> Hi Paul,
>
> On Tue, Feb 17, 2009 at 9:01 PM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
>>
>> For 2 i have fixed this so that resources are correctly cleaned up.
>> It is
>> important for the Apache HTTP client that if you are using
>> ClientResponse
>> without reading an entity (when one is present) or are processing
>> entities
>> that are instances of Closeable that you close the response or stream
>> respectively after you have finished processing the response.
>>
>
> This IMHO is a very important fix and I am glad that now its in the
> trunk.
>

It seems that the Apache HTTP client is less robust with tits
connection caching than HttpURLConnection.

By default an HttpClient is created as follows:

   final HttpClient client = new HttpClient(new
MultiThreadedHttpConnectionManager());

I wonder if there is a better connection manager configuration that
times out connections to avoid the dreadful thread locking issue,
which IMHO is serious issue with the HttpClient, and there are cases
which it can still manifest when developer forgets to close a stream-
based entity.


>> This is fixed in the trunk, and I have updated the JavaDoc of
>> ApacheHttpClient to reflect the changes i have made.
>>
>> So now by default things should work as you initially expected.
>>
>
> Great! I will give the 1.0.3-SNAPSHOT a try sometime later this week.
> Just FYI, I am working on a simple RESTful WS example that uses Jersey
> in Server and Client side along with Spring through and through for
> multi-layer binding plus authentication and authorization. To be
> honest the Jersey mailing list is so helpful that I could not choose
> any other JAX-RS implementation :). Thanks a lot.
>

Thanks. I would like to return the compliment, if you had not given
such details i would not have been able to fix things so quickly.

Paul.