]> source.dussan.org Git - vaadin-framework.git/commitdiff
try to close stream on all types of exceptions
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 15 Oct 2010 14:11:18 +0000 (14:11 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 15 Oct 2010 14:11:18 +0000 (14:11 +0000)
svn changeset:15567/svn branch:6.5

src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java

index 5bff9619a7313a386e4eabb6eaf37626ebe4ff9f..662bdcf7d56c16de36c1905409a1381c5356845b 100644 (file)
@@ -624,12 +624,7 @@ public abstract class AbstractCommunicationManager implements
 
         } catch (UploadInterruptedException e) {
             // Download interrupted by application code
-            try {
-                // still try to close output stream (e.g. file handle)
-                out.close();
-            } catch (IOException e1) {
-                // NOP
-            }
+            tryToCloseStream(out);
             ReceivingFailedEvent event = new ReceivingFailedEventImpl(receiver,
                     filename, type, contentLength, totalBytes, e);
             synchronized (application) {
@@ -638,6 +633,7 @@ public abstract class AbstractCommunicationManager implements
             // Note, we are not throwing interrupted exception forward as it is
             // not a terminal level error like all other exception.
         } catch (final Exception e) {
+            tryToCloseStream(out);
             synchronized (application) {
                 ReceivingFailedEvent event = new ReceivingFailedEventImpl(
                         receiver, filename, type, contentLength, totalBytes, e);
@@ -651,6 +647,17 @@ public abstract class AbstractCommunicationManager implements
         }
     }
 
+    private void tryToCloseStream(OutputStream out) {
+        try {
+            // try to close output stream (e.g. file handle)
+            if (out != null) {
+                out.close();
+            }
+        } catch (IOException e1) {
+            // NOP
+        }
+    }
+
     /**
      * Removes any possible path information from the filename and returns the
      * filename. Separators / and \\ are used.