jpackage test helper function incorrectly removes a directory instead of its contents only

XMLWordPrintable

    • b21
    • generic
    • generic

      In TKit.DirectoryCleaner.accept() at https://github.com/openjdk/jdk/blob/8174cbd5cb797a80d48246a686897ef6fe64ed57/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java#L382 :

      ---
      try (var pathStream = Files.walk(root, 0)) {
        paths = pathStream.collect(Collectors.toList());
      }
      ---

      The intent is to get non-recursive contents of the `root` directory. However `Files.walk(root, 0)` call returns a stream that contains only the `root` itself. This is wrong as it makes the directory cleaner remove the contents of the `root` directory (intended behavior) and the `root` directory itself (NOT intended behavior).

      `Files.walk(root, 0)` should be replaced with `Files.list(root)`.

      The issue impacts only scenarios when jpackage tests are executed on the existing test directories and doesn't impact common scenarios of clean test runs.

            Assignee:
            Alexey Semenyuk
            Reporter:
            Alexey Semenyuk
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: