mirror of https://github.com/apache/maven.git
[MNG-7275] - fixing resource leak due to Files.list
This commit is contained in:
parent
038201e314
commit
5c9512fd8c
|
@ -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 ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue