You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/10/10 10:05:45 UTC
[maven] branch master updated: MNG-7293:fix resource leak due to
Files.walk
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new fbb9d95 MNG-7293:fix resource leak due to Files.walk
fbb9d95 is described below
commit fbb9d95d5048da8dd6896d3d7b82fece74880bcf
Author: lujie <lu...@ict.ac.cn>
AuthorDate: Sat Oct 9 11:04:29 2021 +0800
MNG-7293:fix resource leak due to Files.walk
---
.../src/main/java/org/apache/maven/wrapper/Installer.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java
index 16188cb..14fe29a 100644
--- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java
+++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java
@@ -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 )