- 
    Type:
Bug
 - 
    Resolution: Fixed
 - 
    Priority:
  P4                     
     - 
    Affects Version/s: 21, 23, 24
 - 
    Component/s: tools
 
- 
        b21
 - 
        generic
 - 
        generic
 
---
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.
- backported by
 - 
                    
JDK-8345014 jpackage test helper function incorrectly removes a directory instead of its contents only
-         
     - Resolved
 
 -         
 - 
                    
JDK-8346857 jpackage test helper function incorrectly removes a directory instead of its contents only
-         
     - Resolved
 
 -         
 - 
                    
JDK-8346860 jpackage test helper function incorrectly removes a directory instead of its contents only
-         
     - Resolved
 
 -         
 - 
                    
JDK-8347107 jpackage test helper function incorrectly removes a directory instead of its contents only
-         
     - Resolved
 
 -         
 
- blocks
 - 
                    
JDK-8325089 jpackage utility creates an "infinite", undeleteable directory tree
-         
     - Resolved
 
 -         
 
- links to
 - 
                    
        
        Commit(master)
        openjdk/jdk17u-dev/ac222190
    
 - 
                    
        
        Commit(master)
        openjdk/jdk21u-dev/4474fbca
    
 - 
                    
        
        Commit(master)
        openjdk/jdk/7133d1b9
    
 - 
                    
        
        Review(master)
        openjdk/jdk17u-dev/3165
    
 - 
                    
        
        Review(master)
        openjdk/jdk21u-dev/1286
    
 - 
                    
        
        Review(master)
        openjdk/jdk/21582