cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/5] git commit: Add some extra checks to make sure the temp dir is created and usable
Date Fri, 02 May 2014 14:57:54 GMT
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/a9cab018
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a9cab018
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a9cab018

Branch: refs/heads/2.6.x-fixes
Commit: a9cab01883cae2eff38abce30d846214a935b2f6
Parents: bdef24e
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Apr 30 13:43:30 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri May 2 09:53:54 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/a9cab018/api/src/main/java/org/apache/cxf/helpers/FileUtils.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/helpers/FileUtils.java b/api/src/main/java/org/apache/cxf/helpers/FileUtils.java
index 0c87b54..2bafee2 100644
--- a/api/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/api/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;


Mime
View raw message