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

Project Coin: convert jar and zip util classes and tests to use try-with-resources

XMLWordPrintable

    • b134
    • generic
    • generic
    • Verified

      Findbugs and Jackpot have identified a number of places in the jar and zip implementation classes and tests where try-with-resources can be used. This will fix bugs in certain cases, for example, in src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java there is the following code (near line 240):

              FileInputStream fis = new FileInputStream(inFile);
              run(fis, jstream, mappedFile);
              fis.close();

      If the run() call were to throw an exception, the FileInputStream would be left open. Using try-with-resources the code would be changed to:

              try (FileInputStream fis = new FileInputStream(inFile)) {
                  run(fis, jstream, mappedFile);
              }

      There are a few dozen similar changes in several places in the library and in the corresponding test code.

            smarks Stuart Marks
            smarks Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: