Bug 24897 - Getting IOException when line length exceeds 4096
Summary: Getting IOException when line length exceeds 4096
Status: RESOLVED WONTFIX
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Connector:Coyote (show other bugs)
Version: 5.0.14
Hardware: Other All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 34829 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-21 16:31 UTC by Wenjun
Modified: 2005-05-10 12:27 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wenjun 2003-11-21 16:31:34 UTC
Tomcat generates the following exception when processing a post with a line
longer than 4096 (including the "\n"):

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 com.creditex.util.TestServlet.doPost(TestServlet.java:138)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

The following is source for TestServlet:

  public void doPost(HttpServletRequest request, HttpServletResponse res) 
throws javax.servlet.ServletException  {
    BufferedReader reqReader = null;
    int status = res.SC_OK;
    try{
      reqReader = request.getReader();
      String s = null;
      while ((s=reqReader.readLine()) != null) {
        System.out.println("Read length " + s.length());
      }
    }
    catch(Exception e){
     e.printTrace();
    }
    finally {
      try {
        if (reqReader != null)
          reqReader.close();
        res.setStatus(status);
      } catch (IOException ie) {}
    }
  }

If length is exactly at 4096 (including "\n"), the servlet does not see
the data and no exception is thrown.
Comment 1 Remy Maucherat 2003-11-21 16:48:45 UTC
This is a (reasonable) limit that I did put in on purpose. See the CoyoteReader
source for the constant (and recompile to change it for special purpose
applications).
Comment 2 Alex McCarrier 2005-05-06 22:43:10 UTC
(In reply to comment #1)
> This is a (reasonable) limit that I did put in on purpose. See the CoyoteReader
> source for the constant (and recompile to change it for special purpose
> applications).

I don't understand how this is reasonable.  If someone sending a request to a
webservice, and the request is well formed (doesn't have to have line breaks to
be well formed), and it is a request with a lot of data, then this breaks it. 
Maybe I'm missing something, I don't want to have to force my clients to to
insert line breaks in their XML requests when there is nothing in the W3C
standard that says XML requests have to contain line breaks.

Am I missing something?
Comment 3 Wenjun 2005-05-10 15:40:10 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > This is a (reasonable) limit that I did put in on purpose. See the CoyoteReader
> > source for the constant (and recompile to change it for special purpose
> > applications).
> 
> I don't understand how this is reasonable.  If someone sending a request to a
> webservice, and the request is well formed (doesn't have to have line breaks to
> be well formed), and it is a request with a lot of data, then this breaks it. 
> Maybe I'm missing something, I don't want to have to force my clients to to
> insert line breaks in their XML requests when there is nothing in the W3C
> standard that says XML requests have to contain line breaks.
> 
> Am I missing something?
> 

This seems to have been fixed in version 5.5.4.
Comment 4 Remy Maucherat 2005-05-10 20:26:08 UTC
This cannot be unlimited, so 4KB is a very reasonable constant. Using this
method will make your application *extremely* inefficient, BTW.
Comment 5 Remy Maucherat 2005-05-10 20:27:04 UTC
*** Bug 34829 has been marked as a duplicate of this bug. ***