RFR: 8136895: Writer not closed with disk full error, file resource leaked [v2]
Daniel Jeliński
djelinski at openjdk.org
Wed Apr 19 07:07:44 UTC 2023
On Tue, 18 Apr 2023 17:10:16 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Can we use try-with-resources instead of closing in a finally block? This way if both closing the encoder and closing the underlying stream fail, both exceptions will propagate to the user code.
>
>> Need to think about that scenario a bit to decide if the underlying flush should be done for this case or not.
>
> `flushLeftoverChar()` can throw an exception after having invoked `writeBytes()` once or more. This suggests that a flush of the underlying stream might be warranted.
I think we can assume that every stream implementation will flush before closing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13503#discussion_r1170894528
More information about the nio-dev
mailing list