Bug 38835 - HttpServletRequest.readLine() doesn't block and returns null immediately
Summary: HttpServletRequest.readLine() doesn't block and returns null immediately
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: Unknown
Hardware: All All
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-03 02:29 UTC by Mario Camou
Modified: 2006-03-02 20:22 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Camou 2006-03-03 02:29:02 UTC
I am running 5.5.15 but the list doesn't show it (it only shows up to 5.5.14). I have tried this on Linux 
JDK 1.5.0_06 and Mac OS X JDK 1.5.0_05

This is my servlet code pruned of all nonessentials:

package com.tecnoguru.test;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Test extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse res)
          throws ServletException, IOException {
    doIt(req, res);
  }

  public void doPost(HttpServletRequest req, HttpServletResponse res)
          throws ServletException, IOException {
    doIt(req, res);
  }

  public void doIt(HttpServletRequest req, HttpServletResponse res)
          throws ServletException, IOException {
    BufferedReader rdr = req.getReader();
    PrintWriter wrt = res.getWriter();
    String line = rdr.readLine();
    wrt.println(line);
  }
}

This is the result when doing a telnet to port 8080. Note that I did not do anything after the blank line 
in the request, the response started immediately. The lines I typed are prefixed by >, the lines returned 
are prefixed by <:

>telnet localhost 8080
<Trying ::1...
<Connected to localhost.
<Escape character is '^]'.
>GET /Test/test HTTP/1.0
>
<HTTP/1.1 200 OK
<Server: Apache-Coyote/1.1
<Content-Length: 6
<Date: Fri, 03 Mar 2006 01:15:14 GMT
<Connection: close
<
<null
<Connection closed by foreign host.

>telnet localhost 8080
<Trying ::1...
<Connected to localhost.
<Escape character is '^]'.
>POST /Test/test HTTP/1.0
>
<HTTP/1.1 200 OK
<Server: Apache-Coyote/1.1
<Content-Length: 6
<Date: Fri, 03 Mar 2006 01:15:42 GMT
<Connection: close
<
<null
<Connection closed by foreign host.
Comment 1 william.barker 2006-03-03 05:22:35 UTC
You haven't specified either a Content-Length or a Content-Encoding: chunked 
Request header, so Tomcat is correctly believing that the body of the request 
is empty.  So the Reader correctly returns EOF on all attempts to read the 
body.

Running your test case with a Content-Length request header against SVN trunk 
gives me the expected "Read timed out" exception, after it blocks for the 
configured 15sec.