I think resume was being called twice since this code lives in an abstraction which delegates to a subclass. I moved the resume from the subclass to the superclass and it isn't looping too many times now.
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:16:16 PM
> Subject: Re: NPE in NIOInputStream
> Jon,
> just my guess, are you call response.suspend/resume like in the
> sample [1], see lines 326 and 358?
> WBR,
> Alexey.
> [1]
> http://java.net/projects/grizzly/sources/git/content/samples/http-server-samples/src/main/java/org/glassfish/grizzly/samples/httpserver/nonblockinghandler/NonBlockingHttpHandlerSample.java
> On 07/19/2011 07:08 PM, Jon Brisbin wrote:
> > 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
> > >
> >
>