[java] Explicitly closing the URLClassLoader of the JrtFileSystemProvider

This commit is contained in:
Andreas Dangel
2023-10-26 15:50:15 +02:00
parent d4725e6c1b
commit bf55388e51

View File

@ -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();
}