Details
Description
Originally filed as https://issues.apache.org/jira/browse/FILEUPLOAD-136
The FileUpload library incorrectly tries to read from the underlying InputStream, even after an exception is thrown. I would assume that the correct behavior in this scenario is for the input stream's read() method to return -1 again. Instead, this seems to throw the input stream into an infinite loop.
I have attached code that reproduces this. The output of this program is as following:
2007-07-17 10:50:48.999::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2007-07-17 10:50:49.000::INFO: jetty-6.1.3
2007-07-17 10:50:49.039::INFO: Started SocketConnector @ 0.0.0.0:10000
sending data
input stream is a org.mortbay.jetty.HttpParser$Input
caught exception: org.mortbay.jetty.EofException
trying to read again
Notice that the "last read returned .." line is never printed. At this point, my CPU is pegged to 100% and jstack shows the following stack trace:
Thread 30265: (state = IN_JAVA)
- org.mortbay.jetty.HttpParser.parseNext() @bci=423, line=281 (Compiled frame; information may be imprecise)
- org.mortbay.jetty.HttpParser$Input.blockForContent() @bci=88, line=925 (Compiled frame)
- org.mortbay.jetty.HttpParser$Input.read(byte[], int, int) @bci=4, line=897 (Interpreted frame)
- java.io.InputStream.read(byte[]) @bci=5, line=89 (Interpreted frame)
- TestJetty$1.handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int) @bci=132, line=42 (Interpreted frame)
- org.mortbay.jetty.handler.HandlerWrapper.handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int) @bci=23, line=139 (Interpreted frame)
- org.mortbay.jetty.Server.handle(org.mortbay.jetty.HttpConnection) @bci=110, line=285 (Interpreted frame)
- org.mortbay.jetty.HttpConnection.handleRequest() @bci=131, line=502 (Interpreted frame)
- org.mortbay.jetty.HttpConnection$RequestHandler.content(org.mortbay.io.Buffer) @bci=23, line=835 (Interpreted frame)
- org.mortbay.jetty.HttpParser.parseNext() @bci=2633, line=641 (Interpreted frame)
- org.mortbay.jetty.HttpParser.parseAvailable() @bci=44, line=208 (Interpreted frame)
- org.mortbay.jetty.HttpConnection.handle() @bci=122, line=378 (Interpreted frame)
- org.mortbay.jetty.bio.SocketConnector$Connection.run() @bci=130, line=226 (Interpreted frame)
- org.mortbay.thread.BoundedThreadPool$PoolThread.run() @bci=45, line=442 (Interpreted frame)
Thanks for the report, but I believe this was fixed in 6.1.4.
I just tested your class on 6.1.5rc0 and it returns -1 as expected.
cheers