DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42727>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42727

           Summary: CoyoteReader readLine returns null for some post request
                    bodies that are a multiple of MAX_LINE_LENGTH in size
           Product: Tomcat 5
           Version: 5.5.20
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: Connector:Coyote
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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
()));

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to