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