]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make UploadInterruptedException visible (#12070)
authorFabian Lange <lange.fabian@gmail.com>
Thu, 13 Jun 2013 12:51:08 +0000 (14:51 +0200)
committerVaadin Code Review <review@vaadin.com>
Tue, 9 Jul 2013 08:23:56 +0000 (08:23 +0000)
When another threads interrupts the Upload, the UploadInterruptedException is
thrown. The respective StreamVariable will receive
streamingFailed(StreamingErrorEvent event) which contains the causing exception
via event.getException(). When the UploadInterruptedException is not public, it
is impossible to react on it in the StreamVariable (e.g. treating an
IOException differently from an UploadInterruptedException).

Change-Id: I9098e70e6750c420fcc0978340544e545e237b26

server/src/com/vaadin/server/communication/FileUploadHandler.java

index e9569d45a171fa4b5131c0acf7dcf658e500b568..3f6bfd9267fd756674a18e5b97f2b3a15779e89a 100644 (file)
@@ -38,6 +38,7 @@ import com.vaadin.server.VaadinResponse;
 import com.vaadin.server.VaadinSession;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.UI;
+import com.vaadin.ui.Upload.FailedEvent;
 
 /**
  * Handles a file upload request submitted via an Upload component.
@@ -197,7 +198,19 @@ public class FileUploadHandler implements RequestHandler {
         }
     }
 
-    private static class UploadInterruptedException extends Exception {
+    /**
+     * An UploadInterruptedException will be thrown by an ongoing upload if
+     * {@link StreamVariable#isInterrupted()} returns <code>true</code>.
+     * 
+     * By checking the exception of an {@link StreamingErrorEvent} or
+     * {@link FailedEvent} against this class, it is possible to determine if an
+     * upload was interrupted by code or aborted due to any other exception.
+     */
+    public static class UploadInterruptedException extends Exception {
+
+        /**
+         * Constructs an instance of <code>UploadInterruptedException</code>.
+         */
         public UploadInterruptedException() {
             super("Upload interrupted by other thread");
         }