CAMEL-8032: FileUtil leaks FileInputStream when renameFile fails due to 
permission issue. Thanks to Joe Luo for the patch.


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

Branch: refs/heads/camel-2.13.x
Commit: aae2e24d2c46b38901169a87ec3949fe78a3ed3b
Parents: 2260a1d
Author: Claus Ibsen <[email protected]>
Authored: Tue Nov 11 14:13:45 2014 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Tue Nov 11 14:14:44 2014 +0100

----------------------------------------------------------------------
 camel-core/src/main/java/org/apache/camel/util/FileUtil.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aae2e24d/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java 
b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
index 128c600..61694e3 100644
--- a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
@@ -460,9 +460,11 @@ public final class FileUtil {
     }
 
     public static void copyFile(File from, File to) throws IOException {
-        FileChannel in = new FileInputStream(from).getChannel();
-        FileChannel out = new FileOutputStream(to).getChannel();
+        FileChannel in = null;
+        FileChannel out = null;
         try {
+            in = new FileInputStream(from).getChannel();
+            out = new FileOutputStream(to).getChannel();
             if (LOG.isTraceEnabled()) {
                 LOG.trace("Using FileChannel to copy from: " + in + " to: " + 
out);
             }

Reply via email to