RFR: 8136895: Writer not closed with disk full error, file resource leaked [v2]
Brian Burkhalter
bpb at openjdk.org
Thu Apr 27 00:48:22 UTC 2023
On Wed, 26 Apr 2023 07:23:49 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:
> I still think we should just use `try (ch; out)` and remove the explicit `flush` & `close` calls.
Is this what you mean?
--- a/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java
+++ b/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java
@@ -436,16 +436,7 @@ public final class StreamEncoder extends Writer {
ioe = x;
}
- try {
- if (ch != null)
- ch.close();
- else {
- try {
- out.flush();
- } finally {
- out.close();
- }
- }
+ try (ch; out) {
} catch (IOException e) {
if (ioe != null)
ioe.addSuppressed(e);
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13503#issuecomment-1524291006
More information about the nio-dev
mailing list