users@jersey.java.net

Re: [Jersey] Client: Performance: InputStream fastest possibility?

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 23 Sep 2010 10:15:52 -0700

On Sep 23, 2010, at 1:51 AM, Johannes Schneider wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 09/23/2010 12:00 AM, Paul Sandoz wrote:
>>
>> On Sep 18, 2010, at 10:44 AM, Tatu Saloranta wrote:
>>
>>> On Sat, Sep 18, 2010 at 10:18 AM, Johannes Schneider
>>> <mailings_at_cedarsoft.com> wrote:
>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>> Hash: SHA1
>>>>
>>>> Hi guys,
>>>>
>>>> at the moment I try to optimize some code that fetches a large JSON
>>>> document. I am using the Client provided by Jersey.
>>>>
>>>> At the moment I am calling
>>>>> resource.getEntity( InputStream.class )
>>>>
>>>> My profiler shows me, that the Jackson parser has to wait for the
>>>> stream
>>>> (in HttpInputStream#read) for a long time...
>>>
>>> Sounds like maybe it is being buffered (read completely into in-
>>> memory
>>> buffer) before being handed to Jackson?
>>>
>>
>> Jersey will not buffer the response entity unless you have Jersey
>> logging enabled (using a filter).
>>
>> Are you using the Jersey client with HttpURLConnection or the Apache
>> HTTP client?
>
> I just instantiating the Client without any args. So I think it should
> use a com.sun.jersey.client.urlconnection.URLConnectionClientHandler
>
> But don't exactly know the difference between the two options you
> mentioned...
>

By default Jersey defers to HttpURLConnection, which is what you are
using, but you can also defer to the Apache HTTP client if one needs
additional features.

https://jersey.dev.java.net/nonav/apidocs/1.4/contribs/jersey-apache-client/com/sun/jersey/client/apache/package-summary.html
https://jersey.dev.java.net/nonav/documentation/latest/user-
guide.html#core_client

Difficult to know the reason why the InputStream might be blocking
without knowing more about your environment,

Paul.