-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b132
-
generic
-
generic
-
Verified
Findbugs has flagged some code in the file
src/share/classes/sun/net/www/protocol/jar/URLJarFile.java
as potentially not closing its streams. Specifically, the code
opens streams 'in' and 'out' and attempts to close them in a finally
block at line 236:
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
Unfortunately, if in.close() were to throw an exception, this might
leave out unclosed. There are a few other similar problems as well.
This code can be cleaned up using the new Java 7 try-with-resources
construct. It can also take advantage of the new Files utility method
for copying from a stream to a file.
src/share/classes/sun/net/www/protocol/jar/URLJarFile.java
as potentially not closing its streams. Specifically, the code
opens streams 'in' and 'out' and attempts to close them in a finally
block at line 236:
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
Unfortunately, if in.close() were to throw an exception, this might
leave out unclosed. There are a few other similar problems as well.
This code can be cleaned up using the new Java 7 try-with-resources
construct. It can also take advantage of the new Files utility method
for copying from a stream to a file.
- relates to
-
JDK-7021209 Project Coin: convert JDK core library code to use try-with-resources
-
- Closed
-