On Tue, 7 Dec 2021 14:24:41 GMT, Andrey Turbanov <d...@openjdk.java.net> wrote:

>> 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...

This is legacy code with probably poor testing coverage. Usually we don't print 
anything on the console directly and unconditionally - except in some well 
identified cases. Ignoring exceptions thrown by `close` is a common idiom. That 
said - it does seem that this method is indeed never called - so for the sake 
of simplification I'd agree to keep this change as proposed.
Remind me to sponsor this after the fork.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5818

Reply via email to