From: Fabian Lange Date: Thu, 13 Jun 2013 12:51:08 +0000 (+0200) Subject: Make UploadInterruptedException visible (#12070) X-Git-Tag: 7.1.1~14 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=775c9693e0778894498ff45cac4512fa69e8cb3d;p=vaadin-framework.git Make UploadInterruptedException visible (#12070) 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 --- diff --git a/server/src/com/vaadin/server/communication/FileUploadHandler.java b/server/src/com/vaadin/server/communication/FileUploadHandler.java index e9569d45a1..3f6bfd9267 100644 --- a/server/src/com/vaadin/server/communication/FileUploadHandler.java +++ b/server/src/com/vaadin/server/communication/FileUploadHandler.java @@ -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 true. + * + * 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 UploadInterruptedException. + */ public UploadInterruptedException() { super("Upload interrupted by other thread"); }