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