MNG-7293:fix resource leak due to Files.walk

This commit is contained in:
lujie 2021-10-09 11:04:29 +08:00 committed by Sylwester Lachiewicz
parent ccb76b0db6
commit fbb9d95d50
1 changed files with 7 additions and 4 deletions

View File

@ -34,6 +34,7 @@ import java.util.Formatter;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
@ -140,11 +141,13 @@ public class Installer
private List<Path> listDirs( Path distDir ) throws IOException private List<Path> listDirs( Path distDir ) throws IOException
{ {
return Files.walk( distDir, 1 ) try ( Stream<Path> stream = Files.walk( distDir, 1 ) )
.filter( p -> !distDir.equals( p ) ) {
return stream.filter( p -> !distDir.equals( p ) )
.filter( Files::isDirectory ) .filter( Files::isDirectory )
.collect( Collectors.toList() ); .collect( Collectors.toList() );
} }
}
private void setExecutablePermissions( Path mavenHome ) private void setExecutablePermissions( Path mavenHome )
{ {