You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2021/10/01 07:43:53 UTC

[maven] branch MNG-7275 created (now 5c9512f)

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a change to branch MNG-7275
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at 5c9512f  [MNG-7275] - fixing resource leak due to Files.list

This branch includes the following new commits:

     new 5c9512f  [MNG-7275] - fixing resource leak due to Files.list

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven] 01/01: [MNG-7275] - fixing resource leak due to Files.list

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-7275
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 5c9512fd8c59a8611381529ce1c32e07cb91f16c
Author: lujie <lu...@ict.ac.cn>
AuthorDate: Fri Oct 1 09:08:08 2021 +0800

    [MNG-7275] - fixing resource leak due to Files.list
---
 .../main/java/org/apache/maven/wrapper/BootstrapMainStarter.java   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java
index 515de10..5f81864 100644
--- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java
+++ b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java
@@ -25,6 +25,7 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.stream.Stream;
 
 /**
  * @author Hans Dockter
@@ -49,11 +50,13 @@ public class BootstrapMainStarter
 
     private Path findLauncherJar( Path mavenHome ) throws RuntimeException, IOException
     {
-        return Files.list( mavenHome.resolve( "boot" ) )
-                        .filter( p -> p.getFileName().toString().matches( "plexus-classworlds-.*\\.jar" )  )
+        try ( Stream<Path> list = Files.list( mavenHome.resolve( "boot" ) ) ) 
+        {
+            return list.filter( p -> p.getFileName().toString().matches( "plexus-classworlds-.*\\.jar" )  )
                         .findFirst()
                         .orElseThrow( () -> new RuntimeException(
                                   String.format( "Couldn't locate the Maven launcher JAR in Maven distribution '%s'.",
                                    mavenHome ) ) );
+        }
     }
 }