camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-7055 fixed the test error
Date Wed, 18 Dec 2013 03:34:53 GMT
Updated Branches:
  refs/heads/camel-2.12.x 2e35f212f -> a379a6310


CAMEL-7055 fixed the test error


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a379a631
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a379a631
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a379a631

Branch: refs/heads/camel-2.12.x
Commit: a379a6310df6bee99b12e6c154d75cb74e29dd26
Parents: 2e35f21
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Dec 18 11:05:14 2013 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Dec 18 11:33:40 2013 +0800

----------------------------------------------------------------------
 .../converter/stream/CachedOutputStream.java    | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a379a631/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
b/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
index 0e3540c..f08d52d 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
@@ -66,12 +66,14 @@ public class CachedOutputStream extends OutputStream {
     private File tempFile;
     private FileInputStreamCache fileInputStreamCache;
     private CipherPair ciphers;
+    private final boolean closedOnCompletion;
 
     public CachedOutputStream(Exchange exchange) {
         this(exchange, true);
     }
 
     public CachedOutputStream(Exchange exchange, final boolean closedOnCompletion) {
+        this.closedOnCompletion = closedOnCompletion;
         this.strategy = exchange.getContext().getStreamCachingStrategy();
         currentStream = new CachedByteArrayOutputStream(strategy.getBufferSize());
         
@@ -85,15 +87,15 @@ public class CachedOutputStream extends OutputStream {
                     }
                     if (closedOnCompletion) {
                         close();
+                        try {
+                            cleanUpTempFile();
+                        } catch (Exception e) {
+                            LOG.warn("Error deleting temporary cache file: " + tempFile +
". This exception will be ignored.", e);
+                        }
                     }
                 } catch (Exception e) {
                     LOG.warn("Error closing streams. This exception will be ignored.", e);
                 }
-                try {
-                    cleanUpTempFile();
-                } catch (Exception e) {
-                    LOG.warn("Error deleting temporary cache file: " + tempFile + ". This
exception will be ignored.", e);
-                }
             }
     
             @Override
@@ -109,6 +111,14 @@ public class CachedOutputStream extends OutputStream {
 
     public void close() throws IOException {
         currentStream.close();
+        // need to clean up the temp file this time
+        if (!closedOnCompletion) {
+            try {
+                cleanUpTempFile();
+            } catch (Exception e) {
+                LOG.warn("Error deleting temporary cache file: " + tempFile + ". This exception
will be ignored.", e);
+            }
+        }
     }
 
     public boolean equals(Object obj) {


Mime
View raw message