Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-276

"FileUtils#deleteDirectoryOnExit(File)" does not work

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Commons IO 1.4

      Description

      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?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nkami nkami
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: