[ https://issues.apache.org/jira/browse/MPMD-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17032627#comment-17032627 ]
Andreas Dangel commented on MPMD-297: ------------------------------------- A snapshot of the plugin with this fix is available at [https://repository.apache.org/content/repositories/snapshots/org/apache/maven/plugins/maven-pmd-plugin/3.13.1-SNAPSHOT/] Just use {code:java} <repository> <id>apache.snapshots</id> <url>https://repository.apache.org/content/repositories/snapshots/</url> </repository> {code} and version 3.13.1-SNAPSHOT of maven-pmd-plugin to test. > Classloader not being closed after PMD run > ------------------------------------------ > > Key: MPMD-297 > URL: https://issues.apache.org/jira/browse/MPMD-297 > Project: Maven PMD Plugin > Issue Type: Bug > Reporter: Andreas Dangel > Assignee: Andreas Dangel > Priority: Major > Fix For: 3.14.0 > > Time Spent: 20m > Remaining Estimate: 0h > > 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: > > {code:java} > finally > { > ClassLoader classLoader = pmdConfiguration.getClassLoader(); > if (classLoader instanceof ClasspathClassLoader) > { > IOUtil.tryCloseClassLoader(classLoader); > } > } > {code} > ClasspathClassLoader and IOUtil are from PMD and need to be used until PMD > provides a better API (like pmdConfiguration.close(), etc.). -- This message was sent by Atlassian Jira (v8.3.4#803005)