tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject [PATCH] [Bug 3905] New: - request.getIntputStream()/Reader.close() problem.
Date Tue, 02 Oct 2001 01:42:25 GMT
Since I'm still low on the Karmic scale, I'll post this here.

Basically, I simply implemented the close method in the facade so that it
can continue to be recycled.
----- Original Message -----
From: <bugzilla@apache.org>
To: <tomcat-dev@jakarta.apache.org>
Sent: Monday, October 01, 2001 10:32 AM
Subject: DO NOT REPLY [Bug 3905] New: -
request.getIntputStream()/Reader.close() problem.


> 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=3905>.
> 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=3905
>
> request.getIntputStream()/Reader.close() problem.
>
>            Summary: request.getIntputStream()/Reader.close() problem.
>            Product: Tomcat 3
>            Version: 3.3 Release Candidate 1
>           Platform: Other
>         OS/Version: Linux
>             Status: NEW
>           Severity: Normal
>           Priority: Other
>          Component: Servlet
>         AssignedTo: tomcat-dev@jakarta.apache.org
>         ReportedBy: tom@58k.com
>
>
> In trying to write code that sends an xml packet to a servlet in the
content of
> the request, it appears
> that the tomcat server is not handling the getInputStream() code
correctly.
> What seems to happen is that the first close on the handle of the input
> stream - closes the stream permanently.  This means that the same exact
> request repeated 20 times will work the first time, but not the second
> or any futher beyond the first request.   This problem shows up both
> in 3.3 m4 and 3.3 rc1.  The message that shows up the second time is
"stream
> closed"
>
> My code on the servlet side looks like:
>
> public class processjdist
> {
>     public String contents ="";
>
>     public processjdist()
>     {
>     }
>
>     public init(HttpServletRequest req, HttpServletResponse resp)
>     {
>         out = resp.getOutputStream();
>         try
>          {
>         if (req.getContentLength() > 0)
>         {
>            Reader r = req.getInputStream();
>            BufferedReader bufReader = new BufferedReader(r);
>
>            /// PROBLEM SHOWS UP HERE!!! Second time code is called
>            /// on the server
>            /// error is "Stream closed"
>            while ((line = bufReader.readLine()) != null)
>            {
>                 contents += line;
>            }
>
>            r.close();
>          }
>          } catch (IOException ioe)
>

>
>          }
>     }
>
>     public doPost(HttpServletRequest req, HttpServletResponse resp)
>     {
>         init(req,resp);
>     }
> }
>
> The client side looks like
> public class jdistclient
> {
>      StringBuffer outputBuffer = new StringBuffer();
>      public jdistclient()
>      {
>          String urlString
="http://www.netmech.com/customer/apprequest/get";
>         outputBuffer.append("<request>foo</request>");
>         try
>         {
>             log.debug("fetch from urlFetch");
>             // Send request to web server.
>             URL appreq = new URL(urlString);
>
>
>
>             URLConnection c = appreq.openConnection();
>             log.debug("fetch 1");
>             c.setDoOutput(true);
>             c.setDoInput(true);
>             file://c.setDoInput(true);
>
>             DataOutputStream dout = new
DataOutputStream(c.getOutputStream());
>             log.debug("fetch 1.5");
>
>             log.debug("fetch 2");
>             dout.writeBytes(outputbuffer.toString());
>
>
>             log.debug("fetch 3");
>
>
>             dout.close();
>
>             InputStream is = c.getInputStream();
>             log.debug("fetch 3.1");
>
>
>             log.debug("fetch 3.1.5");
>             InputStreamReader r = new InputStreamReader(is);
>             log.debug("fetch 3.2");
>             BufferedReader in = new BufferedReader(r);
>
>             log.debug("fetch 3.5");
>
>
>             String inputLine;
>              log.debug("fetch 4");
>             while ((inputLine = in.readLine()) != null)
>             {
>                 log.debug(inputLine);
>                 buffer.append(inputLine);
>                 buffer.append("\n");
>             }
>             is.close();
>             in.close();
>
>
>             log.debug("fetch 5");
>
>         }
>         catch (IOException ioe)
>         {
>             log.error("Error:"+ioe.getMessage());
>             String s = ioe.getMessage();
>             System.out.println("Error:"+s);
>             System.out.println(ioe.getLocalizedMessage());
>             System.out.println(ioe.toString());
>         }
>
>
>      }
>
>      public static void main(String [] args)
>      {
>         for (int i=0; i < 20; i++)
>          {
>              jdistclient j = new jdistclient();
>
>          }
>      }
> }
>
>


*----*

This message is intended only for the use of the person(s) listed above 
as the intended recipient(s), and may contain information that is 
PRIVILEGED and CONFIDENTIAL.  If you are not an intended recipient, 
you may not read, copy, or distribute this message or any attachment.  
If you received this communication in error, please notify us immediately 
by e-mail and then delete all copies of this message and any attachments.


In addition you should be aware that ordinary (unencrypted) e-mail sent 
through the Internet is not secure. Do not send confidential or sensitive 
information, such as social security numbers, account numbers, personal 
identification numbers and passwords, to us via ordinary (unencrypted) 
e-mail. 
Mime
View raw message