You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/03/04 19:09:11 UTC

DO NOT REPLY [Bug 27447] New: - CoyoteReader.readLine() read ahead problems

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

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27447

CoyoteReader.readLine() read ahead problems

           Summary: CoyoteReader.readLine() read ahead problems
           Product: Tomcat 5
           Version: 5.0.19
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: rbirch@convergys.com


When posting utf-8 data with either \r\n or \n and that data exceeds the 
MAX_LINE_LENGTH the following I/O exception occurs:
Servlet threw exception
java.io.IOException
	at org.apache.coyote.tomcat5.InputBuffer.reset(InputBuffer.java:463)
	at org.apache.coyote.tomcat5.CoyoteReader.reset(CoyoteReader.java:153)
	at org.apache.coyote.tomcat5.CoyoteReader.readLine
(CoyoteReader.java:207)
	at symhttp.DBRActivationServlet.doPost(DBRActivationServlet.java:31)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:284)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:204)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:257)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:567)
	at org.apache.catalina.core.StandardContextValve.invokeInternal
(StandardContextValve.java:245)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:199)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:567)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:184)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:164)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:149)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:567)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:156)
	at org.apache.catalina.core.StandardValveContext.invokeNext
(StandardValveContext.java:151)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:567)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service
(CoyoteAdapter.java:206)
	at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:833)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnectio
n(Http11Protocol.java:732)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:619)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:688)
	at java.lang.Thread.run(Thread.java:536)

If there are NO \r\n or \n then there is no problem sending data greater than 
MAX_LINE_LENGTH. 

Here is my servlet test code:public void doPost(HttpServletRequest request, 
HttpServletResponse response)
throws ServletException, IOException {
    response.setContentType(CONTENT_TYPE);

    System.out.println("Reading body data\n");
    String contentLen = request.getHeader("Content-Length");
    if ( contentLen != null ) {
      System.out.println("String Content-Length: " + contentLen);
      BufferedReader br = request.getReader();
      String in = null;
      while ( (in = br.readLine()) != null ){
        System.out.println(in);
      }
    } else {
      System.out.println("Null content-length");
    }
    PrintWriter out = response.getWriter();
    sendStuff(out);
  }
  //Clean up resources
  public void destroy() {
  }

I think the problem area is in CoyoteReader.readLine() and the handling of \n 
and \r\n. This seems to be around lines  178 - 194 of  
org.apache.coyote.tomcat5.CoyoteReader.java. 

Problem occurred first in 5.0.16, did an upgrade and still had the problem in 
5.0.19, tried it in some version of Tomcat 4 and had no problems.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org