You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Nobuhiko KAMIKAWA (JIRA)" <ji...@apache.org> on 2011/06/23 03:22:47 UTC

[jira] [Created] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

"FileUtils#deleteDirectoryOnExit(File)" does not work
-----------------------------------------------------

                 Key: IO-276
                 URL: https://issues.apache.org/jira/browse/IO-276
             Project: Commons IO
          Issue Type: Bug
         Environment: Commons IO 1.4
            Reporter: Nobuhiko KAMIKAWA
            Priority: Minor


I called this method, but the target directory was not deleted.


The source of this method is as follows.
----------
    private static void deleteDirectoryOnExit(File directory) throws IOException {
        if (!directory.exists()) {
            return;
        }

        cleanDirectoryOnExit(directory);
        directory.deleteOnExit();
    }
----------
In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.


There is following mention in javadoc of "java.io.File#deleteOnExit".
----------
Files (or directories) are deleted in the reverse order that they are registered.
----------


Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.


How will be it?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

Posted by "Sebb (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13220146#comment-13220146 ] 

Sebb commented on IO-276:
-------------------------

BTW FileUtils#cleanDirectoryOnExit is also a private method
                
> "FileUtils#deleteDirectoryOnExit(File)" does not work
> -----------------------------------------------------
>
>                 Key: IO-276
>                 URL: https://issues.apache.org/jira/browse/IO-276
>             Project: Commons IO
>          Issue Type: Bug
>         Environment: Commons IO 1.4
>            Reporter: nkami
>            Priority: Minor
>         Attachments: IO-276-r1201108-patch.txt
>
>
> I called this method, but the target directory was not deleted.
> The source of this method is as follows.
> ----------
>     private static void deleteDirectoryOnExit(File directory) throws IOException {
>         if (!directory.exists()) {
>             return;
>         }
>         cleanDirectoryOnExit(directory);
>         directory.deleteOnExit();
>     }
> ----------
> In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.
> There is following mention in javadoc of "java.io.File#deleteOnExit".
> ----------
> Files (or directories) are deleted in the reverse order that they are registered.
> ----------
> Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.
> How will be it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

Posted by "Sebb (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved IO-276.
---------------------

       Resolution: Fixed
    Fix Version/s: 2.2
    
> "FileUtils#deleteDirectoryOnExit(File)" does not work
> -----------------------------------------------------
>
>                 Key: IO-276
>                 URL: https://issues.apache.org/jira/browse/IO-276
>             Project: Commons IO
>          Issue Type: Bug
>         Environment: Commons IO 1.4
>            Reporter: nkami
>            Priority: Minor
>             Fix For: 2.2
>
>         Attachments: IO-276-r1201108-patch.txt
>
>
> I called this method, but the target directory was not deleted.
> The source of this method is as follows.
> ----------
>     private static void deleteDirectoryOnExit(File directory) throws IOException {
>         if (!directory.exists()) {
>             return;
>         }
>         cleanDirectoryOnExit(directory);
>         directory.deleteOnExit();
>     }
> ----------
> In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.
> There is following mention in javadoc of "java.io.File#deleteOnExit".
> ----------
> Files (or directories) are deleted in the reverse order that they are registered.
> ----------
> Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.
> How will be it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

Posted by "Ron Kuris (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13148876#comment-13148876 ] 

Ron Kuris commented on IO-276:
------------------------------

I forgot to mention that my patch also actually should fix the reported bug by removing the parent before removing its children.
                
> "FileUtils#deleteDirectoryOnExit(File)" does not work
> -----------------------------------------------------
>
>                 Key: IO-276
>                 URL: https://issues.apache.org/jira/browse/IO-276
>             Project: Commons IO
>          Issue Type: Bug
>         Environment: Commons IO 1.4
>            Reporter: nkami
>            Priority: Minor
>         Attachments: IO-276-r1201108-patch.txt
>
>
> I called this method, but the target directory was not deleted.
> The source of this method is as follows.
> ----------
>     private static void deleteDirectoryOnExit(File directory) throws IOException {
>         if (!directory.exists()) {
>             return;
>         }
>         cleanDirectoryOnExit(directory);
>         directory.deleteOnExit();
>     }
> ----------
> In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.
> There is following mention in javadoc of "java.io.File#deleteOnExit".
> ----------
> Files (or directories) are deleted in the reverse order that they are registered.
> ----------
> Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.
> How will be it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

Posted by "Ron Kuris (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Kuris updated IO-276:
-------------------------

    Attachment: IO-276-r1201108-patch.txt

deleteDirectoryOnExit is a private method. However, you probably meant FileUtils#cleanDirectoryOnExit, which indeed does have this problem.

This is difficult to write a junit test for this.  However, the test code never even calls this method.  I modified the cleanup code to call it; hopefully someone will discover stray files if the cleanDirectoryOnExit method fails.

Patch attached.
                
> "FileUtils#deleteDirectoryOnExit(File)" does not work
> -----------------------------------------------------
>
>                 Key: IO-276
>                 URL: https://issues.apache.org/jira/browse/IO-276
>             Project: Commons IO
>          Issue Type: Bug
>         Environment: Commons IO 1.4
>            Reporter: nkami
>            Priority: Minor
>         Attachments: IO-276-r1201108-patch.txt
>
>
> I called this method, but the target directory was not deleted.
> The source of this method is as follows.
> ----------
>     private static void deleteDirectoryOnExit(File directory) throws IOException {
>         if (!directory.exists()) {
>             return;
>         }
>         cleanDirectoryOnExit(directory);
>         directory.deleteOnExit();
>     }
> ----------
> In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.
> There is following mention in javadoc of "java.io.File#deleteOnExit".
> ----------
> Files (or directories) are deleted in the reverse order that they are registered.
> ----------
> Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.
> How will be it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

Posted by "Sebb (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13220141#comment-13220141 ] 

Sebb commented on IO-276:
-------------------------

The test code needs to clean up as it goes along; so changing it to delete files on exit will likely cause problems.
                
> "FileUtils#deleteDirectoryOnExit(File)" does not work
> -----------------------------------------------------
>
>                 Key: IO-276
>                 URL: https://issues.apache.org/jira/browse/IO-276
>             Project: Commons IO
>          Issue Type: Bug
>         Environment: Commons IO 1.4
>            Reporter: nkami
>            Priority: Minor
>         Attachments: IO-276-r1201108-patch.txt
>
>
> I called this method, but the target directory was not deleted.
> The source of this method is as follows.
> ----------
>     private static void deleteDirectoryOnExit(File directory) throws IOException {
>         if (!directory.exists()) {
>             return;
>         }
>         cleanDirectoryOnExit(directory);
>         directory.deleteOnExit();
>     }
> ----------
> In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.
> There is following mention in javadoc of "java.io.File#deleteOnExit".
> ----------
> Files (or directories) are deleted in the reverse order that they are registered.
> ----------
> Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.
> How will be it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (IO-276) "FileUtils#deleteDirectoryOnExit(File)" does not work

Posted by "Gary D. Gregory (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory closed IO-276.
------------------------------


Version 2.2 has been released and addresses this issue.
                
> "FileUtils#deleteDirectoryOnExit(File)" does not work
> -----------------------------------------------------
>
>                 Key: IO-276
>                 URL: https://issues.apache.org/jira/browse/IO-276
>             Project: Commons IO
>          Issue Type: Bug
>         Environment: Commons IO 1.4
>            Reporter: nkami
>            Priority: Minor
>             Fix For: 2.2
>
>         Attachments: IO-276-r1201108-patch.txt
>
>
> I called this method, but the target directory was not deleted.
> The source of this method is as follows.
> ----------
>     private static void deleteDirectoryOnExit(File directory) throws IOException {
>         if (!directory.exists()) {
>             return;
>         }
>         cleanDirectoryOnExit(directory);
>         directory.deleteOnExit();
>     }
> ----------
> In other words, this method calls "java.io.File#deleteOnExit" in order of "grandchildren -> children -> parent" for files of the target directory hierarchy.
> There is following mention in javadoc of "java.io.File#deleteOnExit".
> ----------
> Files (or directories) are deleted in the reverse order that they are registered.
> ----------
> Therefore, I think the calling order of "java.io.File#deleteOnExit" should be reverse.
> How will be it?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira