-
Bug
-
Resolution: Fixed
-
P3
-
7
-
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.
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.
- relates to
-
JDK-7022624 Project Coin: convert java.io tests to use try-with-resources
-
- Closed
-
-
JDK-7022382 Project Coin: convert pack200 library code to use try-with-resources
-
- Closed
-