Add some extra checks to make sure the temp dir is created and usable
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/aa0179d0 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/aa0179d0 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/aa0179d0 Branch: refs/heads/master Commit: aa0179d0182f0e0a81b4396ceb6b5d89ddb82bae Parents: 2156bf5 Author: Daniel Kulp <[email protected]> Authored: Wed Apr 30 13:43:30 2014 -0400 Committer: Daniel Kulp <[email protected]> Committed: Wed Apr 30 14:53:45 2014 -0400 ---------------------------------------------------------------------- .../java/org/apache/cxf/helpers/FileUtils.java | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/aa0179d0/core/src/main/java/org/apache/cxf/helpers/FileUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java index 0c87b54..2bafee2 100644 --- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java +++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java @@ -32,6 +32,7 @@ import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.SystemPropertyAction; public final class FileUtils { @@ -76,13 +77,26 @@ public final class FileUtils { if (!checkExists.canWrite()) { throw new RuntimeException("The directory " + checkExists.getAbsolutePath() - + " is now writable, please set java.io.tempdir" - + " to an writable directory"); + + " is not writable, please set java.io.tempdir" + + " to a writable directory"); } - File f = new File(s, "cxf-tmp-" + x); + if (checkExists.getUsableSpace() < 1024 * 1024) { + LogUtils.getL7dLogger(FileUtils.class).warning("The directory " + s + " has very " + + "little usable temporary space. Operations" + + " requiring temporary files may fail."); + } + File f = new File(checkExists, "cxf-tmp-" + x); + int count = 0; while (!f.mkdir()) { + + if (count > 10000) { + throw new RuntimeException("Could not create a temporary directory in " + + s + ", please set java.io.tempdir" + + " to a writable directory"); + } x = (int)(Math.random() * 1000000); - f = new File(s, "cxf-tmp-" + x); + f = new File(checkExists, "cxf-tmp-" + x); + count++; } File newTmpDir = f; final File f2 = f;
