Author: markt Date: Wed Jul 30 10:42:11 2008 New Revision: 681139 URL: http://svn.apache.org/viewvc?rev=681139&view=rev Log: Fix bug 44673. Throw IOE if stream is closed and a call is made to any read(), ready(), mark(), reset(), or skip() method as per javadocs for Reader.
Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/InputBuffer.java tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties tomcat/container/tc5.5.x/webapps/docs/changelog.xml tomcat/current/tc5.5.x/STATUS.txt Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/InputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/InputBuffer.java?rev=681139&r1=681138&r2=681139&view=diff ============================================================================== --- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/InputBuffer.java (original) +++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/InputBuffer.java Wed Jul 30 10:42:11 2008 @@ -25,6 +25,7 @@ import java.util.HashMap; import org.apache.catalina.security.SecurityUtil; +import org.apache.catalina.util.StringManager; import org.apache.coyote.Request; import org.apache.tomcat.util.buf.B2CConverter; import org.apache.tomcat.util.buf.ByteChunk; @@ -43,6 +44,11 @@ implements ByteChunk.ByteInputChannel, CharChunk.CharInputChannel, CharChunk.CharOutputChannel { + /** + * The string manager for this package. + */ + protected static StringManager sm = + StringManager.getManager(Constants.Package); // -------------------------------------------------------------- Constants @@ -270,12 +276,20 @@ public int readByte() throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + return bb.substract(); } public int read(byte[] b, int off, int len) throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + return bb.substract(b, off, len); } @@ -330,18 +344,30 @@ public int read() throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + return cb.substract(); } public int read(char[] cbuf) throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + return read(cbuf, 0, cbuf.length); } public int read(char[] cbuf, int off, int len) throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + return cb.substract(cbuf, off, len); } @@ -349,6 +375,10 @@ public long skip(long n) throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + if (n < 0) { throw new IllegalArgumentException(); } @@ -380,6 +410,10 @@ public boolean ready() throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + return (cb.getLength() > 0); } @@ -391,6 +425,10 @@ public void mark(int readAheadLimit) throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + if (cb.getLength() <= 0) { cb.setOffset(0); cb.setEnd(0); @@ -414,6 +452,10 @@ public void reset() throws IOException { + + if (closed) + throw new IOException(sm.getString("inputBuffer.streamClosed")); + if (state == CHAR_STATE) { if (markPos < 0) { cb.recycle(); Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties?rev=681139&r1=681138&r2=681139&view=diff ============================================================================== --- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties (original) +++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties Wed Jul 30 10:42:11 2008 @@ -17,7 +17,6 @@ # # CoyoteConnector # - coyoteConnector.alreadyInitialized=The connector has already been initialized coyoteConnector.alreadyStarted=The connector has already been started coyoteConnector.cannotRegisterProtocol=Cannot register MBean for the Protocol @@ -32,17 +31,14 @@ coyoteConnector.MapperRegistration=register Mapper: {0} coyoteConnector.protocolUnregistrationFailed=Protocol handler stop failed - # # CoyoteAdapter # - coyoteAdapter.service=An exception or error occurred in the container during the request processing # # CoyoteResponse # - coyoteResponse.getOutputStream.ise=getWriter() has already been called for this response coyoteResponse.getWriter.ise=getOutputStream() has already been called for this response coyoteResponse.resetBuffer.ise=Cannot reset buffer after response has been committed @@ -53,7 +49,6 @@ # # CoyoteRequest # - coyoteRequest.getInputStream.ise=getReader() has already been called for this request coyoteRequest.getReader.ise=getInputStream() has already been called for this request coyoteRequest.sessionCreateCommitted=Cannot create a session after the response has been committed @@ -76,5 +71,4 @@ mapperListener.unregisterContext=Unregister Context {0} mapperListener.registerWrapper=Register Wrapper {0} in Context {1} - - +inputBuffer.streamClosed=Stream closed Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=681139&r1=681138&r2=681139&view=diff ============================================================================== --- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original) +++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Wed Jul 30 10:42:11 2008 @@ -49,6 +49,11 @@ Don't throw an ArrayIndexOutOfBoundsException when empty URL is requested. Patch provided by Charles R Caldarale. (markt) </fix> + <fix> + <bug>44673</bug>: Throw IOE if ServletInputStream is closed and a call + is made to any read(), ready(), mark(), reset(), or skip() method as per + javadocs for Reader. (markt) + </fix> </changelog> </subsection> <subsection name="Webapps"> Modified: tomcat/current/tc5.5.x/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/current/tc5.5.x/STATUS.txt?rev=681139&r1=681138&r2=681139&view=diff ============================================================================== --- tomcat/current/tc5.5.x/STATUS.txt (original) +++ tomcat/current/tc5.5.x/STATUS.txt Wed Jul 30 10:42:11 2008 @@ -41,12 +41,6 @@ +1: markt -1: fhanik - Rainer backported all the fixes, we should evaluate those, I'll add them at the bottom -* Fix ServletInputStream still readable when closed - https://issues.apache.org/bugzilla/show_bug.cgi?id=44673 - http://svn.apache.org/viewvc?rev=641076&view=rev - +1: markt, fhanik, yoavs - -1: - * Fix CGI servlet for vista http://people.apache.org/~markt/patches/2008-03-28-cgi-env.patch +1: markt, fhanik, yoavs --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]