From bf55388e518cf4ac7c4d5438f25dfe58b66147d3 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 26 Oct 2023 15:50:15 +0200 Subject: [PATCH] [java] Explicitly closing the URLClassLoader of the JrtFileSystemProvider --- .../pmd/internal/util/ClasspathClassLoader.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java index 839887e2b4..2d5da86589 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java @@ -248,6 +248,14 @@ public class ClasspathClassLoader extends URLClassLoader { public void close() throws IOException { if (fileSystem != null) { fileSystem.close(); + // jrt created an own classloader to load the JrtFileSystemProvider class out of the + // jrt-fs.jar. This needs to be closed manually. + ClassLoader classLoader = fileSystem.getClass().getClassLoader(); + if (classLoader instanceof URLClassLoader) { + ((URLClassLoader) classLoader).close(); + } + packagesDirsToModules = null; + fileSystem = null; } super.close(); }