From 29216ce18884f1465ebc744aff0b5e28c24702bd Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Fri, 15 Oct 2010 14:11:18 +0000 Subject: [PATCH] try to close stream on all types of exceptions svn changeset:15567/svn branch:6.5 --- .../server/AbstractCommunicationManager.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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. -- 2.39.5