users@grizzly.java.net

Re: NPE in NIOInputStream

From: Jon Brisbin <jon_at_jbrisbin.com>
Date: Tue, 19 Jul 2011 12:08:07 -0500 (CDT)

I'm sorry but I can't.

Thanks!

Jon Brisbin
http//jbrisbin.com

----- Original Message -----

> From: "Oleksiy Stashok" <oleksiy.stashok_at_oracle.com>
> To: users_at_grizzly.java.net
> Sent: Tuesday, July 19, 2011 12:04:58 PM
> Subject: Re: NPE in NIOInputStream

> Hi Jon,

> can you pls. share the entire HttpHandler code?

> Thanks.

> WBR,
> Alexey.

> On 07/19/2011 07:01 PM, Jon Brisbin wrote:
> > I've moved my code to using the Grizzly HTTP abstractions to handle
> > Expect: 100-continue thing. Now I'm getting an NPE and I can't
> > figure out what I need to be doing differently.
>

> > I'm processing an upload and I'm using the non-blocking
> > NIOInputStream. My ReadHandler is blowing up in the "readAvailable"
> > method:
>

> > @Override public void onAllDataRead() throws Exception {
>
> > readAvailable();
>
> > mongoTemplate.save(meta);
>
> > metadata.remove(request.getContext().getAttributes());
>
> > }
>

> > private void readAvailable() throws IOException {
>
> > log.debug("readAvailable: " + requestIn);
>
> > while (requestIn.isReady()) { // <- Explodes here on second time
> > around
>
> > }
>
> > }
>

> > The NPE occurs on the second time through the while loop. It looks
> > like I've read all my data and the NIOInputStream is being eagerly
> > recycled because the next call to isReady() gives me an NPE.
>

> > I'm going on the examples that have this loop in it but it's not
> > obvious to me why I even need it. Since I'm specifying a size to
> > wait for, can't I just read available() || BUFFER_SIZE?
>

> > Thanks!
>

> > Jon Brisbin
>
> > http//jbrisbin.com
>