cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sea...@apache.org
Subject svn commit: r723778 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/helpers/FileUtils.java test/java/org/apache/cxf/helpers/FileUtilsTest.java
Date Fri, 05 Dec 2008 16:02:52 GMT
Author: seanoc
Date: Fri Dec  5 08:02:52 2008
New Revision: 723778

URL: http://svn.apache.org/viewvc?rev=723778&view=rev
Log:
Fix for CXF-1924. 
Infinite loop in FileUtils.getDefaultTempDir() when "java.io.tmpdir" directory does not exist.

Added:
    cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?rev=723778&r1=723777&r2=723778&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java Fri Dec  5
08:02:52 2008
@@ -56,6 +56,12 @@
         if (s == null) {
             int x = (int)(Math.random() * 1000000);
             s = System.getProperty("java.io.tmpdir");
+            File checkExists = new File(s);
+            if(!checkExists.exists()) {
+                throw new RuntimeException("The directory " 
+                                       + checkExists.getAbsolutePath() 
+                                       + " does not exist, please set java.io.tempdir to
an existing directory");
+            }
             File f = new File(s, "cxf-tmp-" + x);
             while (!f.mkdir()) {
                 x = (int)(Math.random() * 1000000);

Added: cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java?rev=723778&view=auto
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java (added)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/helpers/FileUtilsTest.java Fri Dec
 5 08:02:52 2008
@@ -0,0 +1,22 @@
+package org.apache.cxf.helpers;
+
+import java.io.File;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FileUtilsTest extends Assert {
+    
+    
+    @Test
+    public void testTempIODirExists() throws Exception {
+
+        try {
+            System.setProperty("java.io.tmpdir", "dummy");
+            FileUtils.createTempFile("foo", "bar");
+        } catch (RuntimeException e) {
+            assertTrue(e.toString().contains("please set java.io.tempdir to an existing directory"));
+        }    
+    }
+}



Mime
View raw message