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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 21, 23, 24
    • tools
    • 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.

            asemenyuk Alexey Semenyuk
            asemenyuk Alexey Semenyuk
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: