From: Matti Tahvonen Date: Fri, 15 Oct 2010 14:11:18 +0000 (+0000) Subject: try to close stream on all types of exceptions X-Git-Tag: 6.7.0.beta1~983 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=29216ce18884f1465ebc744aff0b5e28c24702bd;p=vaadin-framework.git try to close stream on all types of exceptions svn changeset:15567/svn branch:6.5 --- diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 5bff9619a7..662bdcf7d5 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -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.