i have a webapp running on jboss-4.0.5.GA/apache-tomcat-5.5.20 that reads in the http post request body and processes it. i noticed that for request bodies that didn't contain line separators and that had sizes that were exact multiples of org.apache.catalina.connector.CoyoteReader.MAX_LINE_LENGTH (4096), i was receiving null when calling org.apache.catalina.connector.CoyoteReader.readLine (). i believe that the problem is at line 155 in org.apache.catalina.connector.CoyoteReader, where on the last iteration through the loop, "pos" does equal zero and null is returned even though data has been aggregated. here's a command to run in cygwin to easily reproduce the problem: for requestSize in 4095 4096 4097 8191 8192 8193; do dd if=/dev/zero bs=1c count=$requestSize | tr '\000' 'A' | curl --data-binary @- http://localhost:8080/DebugJboss/DebugServlet > $requestSize.txt; done; output from directory listing (size filename): 4095 4095.txt 0 4096.txt 4097 4097.txt 8191 8191.txt 0 8192.txt 8193 8193.txt here's the bulk of the servlet code i used to reproduce the problem: public class DebugServlet extends HttpServlet { protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { BufferedReader br = arg0.getReader(); Writer writer = arg1.getWriter(); String line = null; while ((line = br.readLine()) != null) { writer.write(line); } writer.close(); br.close(); } } it appears that a workaround is to wrap the requests's input stream instead: BufferedReader br = new BufferedReader(new InputStreamReader(arg0.getInputStream ()));
Created attachment 20405 [details] Checks aggregator==null before returning null I attached a patch to check that aggregator==null before returning null.
*** Bug 44060 has been marked as a duplicate of this bug. ***
I have reproduce similar behavior. I cannot read anything from ServletRequest.getInputStream or getReader for Tomcat ver 5.5.15+. Any idea? Regards Mladen
Any chance of getting this fix in tomcat 5.5 ? After a few hours of debugging my application, i finally discovered this bug was the root cause. It's still there in Tomcat 5.5.26.
Thanks for the patch. It has been applied to trunk and proposed for 6.0.x and 5.5.x.
This has been fixed in 5.5.x and will be included in 5.5.27 onwards.