Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8184961

jdk.test.lib.util.FileUtils.deleteFileWithRetry0 should wait for absence of a file

    XMLWordPrintable

Details

    • b17

    Description

      We have several intermittent issues on Windows relative to FileUtils
      see
      https://bugs.openjdk.java.net/browse/JDK-8177357 and https://bugs.openjdk.java.net/browse/JDK-8169971

      My understanding of the root cause is following
      When test working directory is cleaned up after a test case there are open file handlers. Perhaps due to McAfee scanner or another software which analyzes files created by test in background.
      If so the deleted file just is marked for deletion. It actually exists in the working directory unless all open handlers will be closed. But Files.exists() will return false for such file marked for deletion. And FileUtils relays on the exists() method in waiting loop which checks that file is deleted. We actually should check for absence of the file not for presence.

      The following code on Windows prints false in both cases

      public static void main(String[] args) throws Exception {
              Path tmp = Paths.get("tmp");
              Files.createDirectories(tmp);
              Path file = tmp.resolve("file.txt");
              BufferedWriter bw = Files.newBufferedWriter(file);//save handle to file
              Files.delete(file); //mark for deletion on windows
              System.out.println("Files.exists(): " + Files.exists(file) );
              System.out.println("Files.notExists(): " + Files.notExists(file));
                      bw.close();
          }

      What's why we get DirectoryNotEmptyException

      Attachments

        Issue Links

          Activity

            People

              anazarov Andrey Nazarov (Inactive)
              anazarov Andrey Nazarov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: