Description
In order to support type resolution, PMD uses the compile-time classpath of the analyzed project in order to resolve types. This is done by creating a extra URLClassloader. However, this classloader is not closed at the end of the PMD run which causes file leaks and might lead to "too many open files" errors for large projects.
See MNG-6836.
The classloader should be closed here in PmdReport (https://github.com/apache/maven-pmd-plugin/blob/0068cebdad1c79ffa21bba648cbfb7e6c2007da9/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java#L568-L569)
with e.g. the following code:
finally { ClassLoader classLoader = pmdConfiguration.getClassLoader(); if (classLoader instanceof ClasspathClassLoader) { IOUtil.tryCloseClassLoader(classLoader); } }
ClasspathClassLoader and IOUtil are from PMD and need to be used until PMD provides a better API (like pmdConfiguration.close(), etc.).
Attachments
Issue Links
- is related to
-
MNG-6836 Too Many Open Files for large projects
- Open
- links to