RFR: 8274809: Update java.base classes to use try-with-resources [v4]
Andrey Turbanov
duke at openjdk.java.net
Tue Dec 7 14:28:18 UTC 2021
On Tue, 7 Dec 2021 11:41:12 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8274809: Update java.base classes to use try-with-resources
>> fix review comments
>
> src/java.base/share/classes/sun/net/www/MimeTable.java line 385:
>
>> 383:
>> 384: protected boolean saveAsProperties(File file) {
>> 385: try (FileOutputStream os = new FileOutputStream(file)) {
>
> This is not strictly equivalent as now an exception thrown during `close()` will be printed instead of being ignored. I have no idea whether it's a good thing or a bad thing, but that's a _different_ thing...
> So unless someone with more historical knowledge of this area can comment, maybe this change should be reverted.
I believe it's always good to have at least _some_ trace if we got Exception. If closing FileOutputStream failed - there is no guarantee, that all written content is actually stored to filesystem.
BTW, this method `saveAsProperties` seems unused...
-------------
PR: https://git.openjdk.java.net/jdk/pull/5818
More information about the security-dev
mailing list