Repository: camel Updated Branches: refs/heads/camel-2.13.x aca025602 -> 85f6210e4 refs/heads/camel-2.14.x aed8459db -> af0280f67
CAMEL-8121 Fixed the issue that Infinite Loop Within Camel if the temp file directory is not writable Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/af0280f6 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/af0280f6 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/af0280f6 Branch: refs/heads/camel-2.14.x Commit: af0280f676d8bc99965c2234a0e998d679a03fde Parents: aed8459 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Thu Dec 4 10:37:18 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Thu Dec 4 10:41:55 2014 +0800 ---------------------------------------------------------------------- .../main/java/org/apache/camel/util/FileUtil.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/af0280f6/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 61694e3..abedc64 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 @@ -324,13 +324,28 @@ public final class FileUtil { + " does not exist, please set java.io.tempdir" + " to an existing directory"); } + + if (!checkExists.canWrite()) { + throw new RuntimeException("The directory " + + checkExists.getAbsolutePath() + + " is not writable, please set java.io.tempdir" + + " to a writable directory"); + } // create a sub folder with a random number Random ran = new Random(); int x = ran.nextInt(1000000); - File f = new File(s, "camel-tmp-" + x); + int count = 0; + // Let us just try 100 times to avoid the infinite loop while (!f.mkdir()) { + count++; + if (count >= 100) { + throw new RuntimeException("Camel cannot a temp directory from" + + checkExists.getAbsolutePath() + + " 100 times , please set java.io.tempdir" + + " to a writable directory"); + } x = ran.nextInt(1000000); f = new File(s, "camel-tmp-" + x); }