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 2002/08/13 04:05:35 UTC

DO NOT REPLY [Bug 11645] New: - RequestStream and HttpRequestStream throw an IOException when calling close on an already closed stream

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=11645>.
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=11645

RequestStream and HttpRequestStream throw an IOException when calling close on an already closed stream

           Summary: RequestStream and HttpRequestStream throw an IOException
                    when calling close on an already closed stream
           Product: Tomcat 4
           Version: 4.0.4 Final
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: tucu@uol.com.ar


Both 
catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java
and 
catalina/src/share/org/apache/catalina/connector/ResponseStream.java
throw a IOException when calling close and the stream is already closed. Since 
the is no way to check if a InputStream is open the close method should not 
throw an Exception if the stream is already close (the InputStream classes in 
the JDK do this). The close method should look like these in both cases:

/**
* Close this input stream.  No physical level I-O is performed, but
* any further attempt to read from this stream will throw an IOException.
* If a content length has been set but not all of the bytes have yet been
* consumed, the remaining bytes will be swallowed.
*/
public void close() throws IOException {
   if (closed)
      //throw new IOException(sm.getString("requestStream.close.closed"));
      return;
   if (length > 0) {
      while (count < length) {
         int b = read();
            if (b < 0)
               break;
      }
   }
   closed = true;
}
This bug applies to tomcat 4.1.7 too.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>