views:

125

answers:

0

I built a restful ajax app using Java and servlets. When making POST requests, I send json in the body, but when making GET requests, I rely solely on the URL. While testing, I made it so that the app gets the raw request body using HttpServletRequest.getReader on each request, no matter what. What I found was that extremely rarely and seemingly randomly I would sometimes get some json data on a GET request, even though none should be sent.

Is it possible that a reader is somehow being recycled with old data? I have never seen anything in documentation that getReader on a GET request was illegal or unspecified, I just assumed it would always be an empty string.

I suppose that I may have introduced a bug somewhere. I have a very slim abstraction layer over getting the request body as a string, but I really don't think thats it.

I can easily avoid the problem by not checking the request body on a GET request, but I wanted to figure out what was causing the behavior first. I'm using Jetty 6 embedded when I see the behavior. Not sure if there could be a bug there.