You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andreas Dangel (Jira)" <ji...@apache.org> on 2020/02/07 19:49:00 UTC

[jira] [Assigned] (MPMD-297) Classloader not being closed after PMD run

     [ https://issues.apache.org/jira/browse/MPMD-297?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Dangel reassigned MPMD-297:
-----------------------------------

    Assignee: Andreas Dangel

> 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: 10m
>  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)