Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8233680

JavacFileManager.close() doesn't clear some cache instance variables

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 13.0.1
    • Fix Version/s: 14
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      A DESCRIPTION OF THE PROBLEM :
      https://bugs.openjdk.java.net/browse/JDK-8220792 introduced two closely related regressions. The root cause is pathsAndContainersByLocationAndRelativeDirectory and nonIndexingContainersByLocation are not cleared in JavacFileManager.close().

      1. Holding on to JavacFileManager$ArchiveContainer that are already closed: a java.nio.file.ClosedFileSystemException is thrown when any of of these closed ArchiveContainer.list() is called again.

      2. Increased memory usage for compilation/documentation tasks: https://github.com/gradle/gradle/issues/11097. https://docs.google.com/spreadsheets/d/121U52kf4NUdhrMD9NMOxPHsQUzHx0SyMfFqDaoZnG5Y measured the time before and after the cache instance variables were added. We should measure the memory usage before and after as well.

      A patch is provided at https://github.com/GreenRecycleBin/JDK-8220792-Regression/blob/master/JDK-8220792-Regression.patch. The patch doesn't loop through all the values of the two cache instance variables and call close() on them because they are the same as those in the "containers" instance variable and the containers for-loop closing already do that.

      REGRESSION : Last worked in version 11.0.5

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      First regression:
        - $ git clone https://github.com/GreenRecycleBin/JDK-8220792-Regression
        - $ cd JDK-8220792-Regression
        - $ ./run-reproducible-code.sh <JDK 11 javac> <JRE 11 java> <JRE 13 java>

      Second regression: see https://github.com/gradle/gradle/issues/11097

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      First regression:
        - "Expected behavior: exits normally." in the output

      Second regression: increased memory usage for compilation/documentation tasks is not sustained after they have finished
      ACTUAL -
      First regression:
        - "Actual behavior: throws an exception." followed by a java.nio.file.ClosedFileSystemException stack trace in the output

      Second regression: increased memory usage for compilation/documentation tasks is sustained after they have finished

      ---------- BEGIN SOURCE ----------
      First regression: https://github.com/GreenRecycleBin/JDK-8220792-Regression
      Second regression: https://github.com/gradle/gradle/issues/11097
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Both regression:
        - $ git clone https://github.com/GreenRecycleBin/JDK-8220792-Regression
        - $ cd JDK-8220792-Regression
        - $ ./run-workaround-code.sh <JDK 11 javac> <JRE 11 java> <JRE 13 java>

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: