Uploaded image for project: 'Maven PMD Plugin'
  1. Maven PMD Plugin
  2. MPMD-297

Classloader not being closed after PMD run

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.14.0
    • PMD
    • None

    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

          Activity

            People

              adangel Andreas Dangel
              adangel Andreas Dangel
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m