RFR: 8136895: Writer not closed with disk full error, file resource leaked

Alan Bateman alanb at openjdk.org
Tue Apr 18 07:23:46 UTC 2023


On Tue, 18 Apr 2023 02:03:19 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> In`StreamEncoder::implClose`, move `flushLeftoverChar()` inside the `try` block and the closing of the underlying stream inside the `finally` block.

test/jdk/java/nio/channels/Channels/Close.java line 37:

> 35: import java.nio.charset.StandardCharsets;
> 36: 
> 37: public class Close {

I assume we should add a test/jdk/java/io/OutputStreamWriter for this scenario too.

The Writer returned by Channels.newWriter also uses StreamEncoder so adding a test to  test/jdk/java/nio/channels/Channels/ is good too. The test is not a unit test for close, but a regression test for a specific scenario so probably should be renamed to something like CloseWriterWithFailingFlush or something like that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13503#discussion_r1169602586


More information about the nio-dev mailing list