Author: sebb
Date: Thu Mar  1 17:18:00 2012
New Revision: 1295683

URL: http://svn.apache.org/viewvc?rev=1295683&view=rev
Log:
IO-276 "FileUtils#deleteDirectoryOnExit(File)" does not work

Modified:
    commons/proper/io/trunk/src/changes/changes.xml
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
    
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsTestCase.java

Modified: commons/proper/io/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/changes/changes.xml?rev=1295683&r1=1295682&r2=1295683&view=diff
==============================================================================
--- commons/proper/io/trunk/src/changes/changes.xml (original)
+++ commons/proper/io/trunk/src/changes/changes.xml Thu Mar  1 17:18:00 2012
@@ -40,6 +40,9 @@ The <action> type attribute can be add,u
 
   <body>
     <release version="2.2" date="TBA">
+      <action dev="sebb" type="fix" issue="IO-276" due-to="nkami">
+        "FileUtils#deleteDirectoryOnExit(File)" does not work
+      </action>        
       <action dev="sebb" type="fix" issue="IO-273" due-to="sebb">
         BoundedInputStream.read() treats max differently from 
BoundedInputStream.read(byte[]...)
       </action>        

Modified: 
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java?rev=1295683&r1=1295682&r2=1295683&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java 
(original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java 
Thu Mar  1 17:18:00 2012
@@ -2061,10 +2061,10 @@ public class FileUtils {
             return;
         }
 
+        directory.deleteOnExit();
         if (!isSymlink(directory)) {
             cleanDirectoryOnExit(directory);
         }
-        directory.deleteOnExit();
     }
 
     /**

Modified: 
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsTestCase.java?rev=1295683&r1=1295682&r2=1295683&view=diff
==============================================================================
--- 
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
 (original)
+++ 
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
 Thu Mar  1 17:18:00 2012
@@ -2254,6 +2254,15 @@ public class FileUtilsTestCase extends F
         }
     }
 
+    public void testIO276() throws Exception {
+        File dir = new File("target", "IO276");
+        assertTrue(dir+" should not be present",dir.mkdirs());
+        File file = new File(dir,"IO276.txt");
+        assertTrue(file+" should not be present",file.createNewFile());
+        FileUtils.forceDeleteOnExit(dir); 
+        // If this does not work, test will fail next time (assuming target is 
not cleaned)
+    }
+
     /**
      * DirectoryWalker implementation that recursively lists all files and 
directories.
      */


Reply via email to