Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 78135 invoked from network); 17 Jul 2007 20:06:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jul 2007 20:06:32 -0000 Received: (qmail 7150 invoked by uid 500); 17 Jul 2007 20:06:28 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 7059 invoked by uid 500); 17 Jul 2007 20:06:28 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 7047 invoked by uid 99); 17 Jul 2007 20:06:27 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2007 13:06:27 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2007 13:06:25 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AA2C2714204 for ; Tue, 17 Jul 2007 13:06:04 -0700 (PDT) Message-ID: <15183972.1184702764694.JavaMail.jira@brutus> Date: Tue, 17 Jul 2007 13:06:04 -0700 (PDT) From: "Jochen Wiedmann (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Commented: (FILEUPLOAD-136) FileUpload race condition with used with Jetty 6 In-Reply-To: <23342605.1181622266129.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/FILEUPLOAD-136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12513345 ] Jochen Wiedmann commented on FILEUPLOAD-136: -------------------------------------------- I assume, you are referring to the ItemInputStream, are you? The ItemInputStream is returned to the user, if he or she iterates over the multipart streams parts. The user *may* close this InputStream, but there's no requirement that he *must* close it. Even more, the user is not required to consume the InputStream's contents. For example, the user might read the first line, detects that he is not interested in this item and calls FileItemIterator.next(). At that point, we are in the middle of a part's body. In order to skip this body, we need to find the next boundary, which is exactly what ItemInputStream.close() does for us. > FileUpload race condition with used with Jetty 6 > ------------------------------------------------ > > Key: FILEUPLOAD-136 > URL: https://issues.apache.org/jira/browse/FILEUPLOAD-136 > Project: Commons FileUpload > Issue Type: Bug > Affects Versions: 1.2 > Environment: Running on Windows XP SP2 with Jetty 6 embedded and Firefox 2.0.0.4 > Reporter: Keith Kowalczykowski > Priority: Critical > Attachments: FileUploadTest.zip, TestJetty.java > > > When running commons file upload with Jetty 6, ServletFileUpload.parseRequest spins and never returns when the user clicks the "stop" button in their browser while an upload is in progress. > Reproduction Steps: > * Create a simple servlet / html form which accepts a file upload using commons file upload (or use the example code below). > * Upload a sufficiently large file that you have time to click the stop button before the upload completes. > * Observe that the thread is now stuck within file upload. > Other Information: > Using jstack, I was able to get the following trace of where it is blocking. It looks like it is on a read() call that file upload is making. > at org/mortbay/jetty/HttpParser$Input.blockForContent(HttpParser.java:922) > at org/mortbay/jetty/HttpParser$Input.read(HttpParser.java:897) > at org/apache/commons/fileupload/MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:959) > at org/apache/commons/fileupload/MultipartStream$ItemInputStream.close(MultipartStream.java:910) > at org/apache/commons/fileupload/util/Streams.copy(Streams.java:119) > at org/apache/commons/fileupload/util/Streams.copy(Streams.java:64) > at org/apache/commons/fileupload/FileUploadBase.parseRequest(FileUploadBase.java:354) > at org/apache/commons/fileupload/servlet/ServletFileUpload.parseRequest(ServletFileUpload.java:126) > at test/Main$1.handle(Main.java:43) > at org/mortbay/jetty/handler/HandlerWrapper.handle(HandlerWrapper.java:139) > at org/mortbay/jetty/Server.handle(Server.java:285) > at org/mortbay/jetty/HttpConnection.handleRequest(HttpConnection.java:502) > at org/mortbay/jetty/HttpConnection$RequestHandler.content(HttpConnection.java:835) > at org/mortbay/jetty/HttpParser.parseNext(HttpParser.java:641) > at org/mortbay/jetty/HttpParser.parseAvailable(HttpParser.java:208) > at org/mortbay/jetty/HttpConnection.handle(HttpConnection.java:378) > at org/mortbay/jetty/bio/SocketConnector$Connection.run(SocketConnector.java:226) > at org/mortbay/thread/BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442) > at jrockit/vm/RNI.c2java(IIII)V(Native Method) > -- end of trac > Originally I thought this was an issue with our code, however, I have since isolated it to a simple test case. Bellow is a class file called Main which when run will instantiate an instance of Jetty on port 8080 and an HTML document that will post a file upload to the servlet. When the stop button is pressed, you will see that the line "Starting processing" is printed, but neither the "Exception occured in processing" or "Processing completed" are printed. I have a full eclipse project (jars and all) on my machine that I was planning on uploading with this ticket, however, I don't see a way to attach a file. Therefore, I have copied and pasted the two files bellow. Let me know if you want the full project. > === Main.java === > /** > * > */ > package test; > import java.io.IOException; > import java.util.List; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > import org.apache.commons.fileupload.FileItem; > import org.apache.commons.fileupload.disk.DiskFileItemFactory; > import org.apache.commons.fileupload.servlet.ServletFileUpload; > import org.mortbay.jetty.Handler; > import org.mortbay.jetty.Server; > import org.mortbay.jetty.handler.AbstractHandler; > /** > * @author Keith Kowalczykowski > * > */ > public class Main { > public static void main(String[] args) { > Handler handler = new AbstractHandler() { > public void handle(String arg0, HttpServletRequest arg1, > HttpServletResponse arg2, int arg3) throws IOException, > ServletException > { > System.out.println("Starting processing"); > try > { > // Create a factory for disk-based file items > DiskFileItemFactory factory = new DiskFileItemFactory(); > > // Create a new file upload handler > ServletFileUpload upload = new ServletFileUpload(factory); > > // Parse the request > List items = upload.parseRequest(arg1); > for (int i = 0; i < items.size(); i++) > { > FileItem file_item = (FileItem) items.get(i); > > System.out.println("Field Name: " + file_item.getFieldName()); > } > } > catch (Exception e) > { > e.printStackTrace(); > System.out.println("Exception occured in processing"); > } > finally > { > System.out.println("Processing completed"); > } > } > }; > try > { > Server server = new Server(8080); > server.setHandler(handler); > server.start(); > } > catch (Exception e) > { > > } > } > } > === HTML Document === > > > > >
> > >
> > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org