users@jersey.java.net

Re: [Jersey] NPE at AbstractMessageReaderWriterProvider.readFromAsString()

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Tue, 9 Dec 2008 21:41:40 -0800 (PST)

I figured it out. It looks like I can invoke
ClientResponse.getEntity(String.class) once, but if I invoke it twice
consecutively this exception is thrown. This is caused by the fact that
URLConnectionClientHandler.java line 160 sets "in" (the InputStream) to
null. I posted this bug report:
https://jersey.dev.java.net/issues/show_bug.cgi?id=159

I pointed out one possible fix though I will be the first to admit that it
is a little hairy. Hopefully you will find a cleaner solution.

Thank you,
Gili


Gili wrote:
>
> Hi Paul,
>
> I get this exception in jersey-client when I invoke
> ClientResponse.getEntity(String.class):
>
> java.lang.NullPointerException
> at java.io.Reader.<init>(Reader.java:61)
> at java.io.InputStreamReader.<init>(InputStreamReader.java:96)
> at
> com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.readFromAsString(AbstractMessageReaderWriterProvider.java:85)
> at
> com.sun.jersey.core.impl.provider.entity.StringProvider.readFrom(StringProvider.java:70)
> at
> com.sun.jersey.core.impl.provider.entity.StringProvider.readFrom(StringProvider.java:55)
> at
> com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler$URLConnectionResponse.getEntity(URLConnectionClientHandler.java:156)
> at
> com.sun.jersey.client.impl.urlconnection.URLConnectionClientHandler$URLConnectionResponse.getEntity(URLConnectionClientHandler.java:138)
> at
> adcaster.shared.persistence.Resources$IOExceptionBuilder.cause(Resources.java:192)
>
>
> Please confirm.
>
> Thanks,
> Gili
>

-- 
View this message in context: http://n2.nabble.com/NPE-at-AbstractMessageReaderWriterProvider.readFromAsString%28%29-tp1636314p1637389.html
Sent from the Jersey mailing list archive at Nabble.com.