You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/07/23 13:35:20 UTC
[maven-war-plugin] branch master updated: Avoid resource leak from
class loader (#16)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 94baefb Avoid resource leak from class loader (#16)
94baefb is described below
commit 94baefbbddaf64b944a0bb27be8e007ad5f15db2
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Thu Jul 23 13:33:04 2020 +0000
Avoid resource leak from class loader (#16)
* close ClassLoader
---
.../java/org/apache/maven/plugins/war/WarMojo.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/war/WarMojo.java b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
index e30c571..3dda4c9 100644
--- a/src/main/java/org/apache/maven/plugins/war/WarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
@@ -313,9 +313,22 @@ public class WarMojo
{
urls[i] = new File( classpathElements.get( i ) ).toURI().toURL();
}
- ClassLoader loader = new URLClassLoader( urls, Thread.currentThread().getContextClassLoader() );
-
- return hasWebServletAnnotationClassInClasspath( loader );
+ URLClassLoader loader = new URLClassLoader( urls, Thread.currentThread().getContextClassLoader() );
+ try
+ {
+ return hasWebServletAnnotationClassInClasspath( loader );
+ }
+ finally
+ {
+ try
+ {
+ loader.close();
+ }
+ catch ( IOException ex )
+ {
+ // ignore
+ }
+ }
}
private static boolean hasWebServletAnnotationClassInClasspath( ClassLoader loader )