RFR: 8232003: (fs) Files.write can leak file descriptor in the exception case

Severin Gehwolf sgehwolf at redhat.com
Tue Oct 8 17:02:23 UTC 2019


Hi,

Could I please get a review of this fix for a resource leak on the
exception path in Files.write? The resource leak can surface, for
example, when the underlying filesystem runs out of disk space, but
some user code catches IOException and continues to try to write to
some path on the full disk. The bug has some details.

The proposed fix is to use try-with-resouces on the opened OutputStream
in Files.write() in a similar way as is being done with the buffered
writer.

Bug: https://bugs.openjdk.java.net/browse/JDK-8232003
webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8232003/01/webrev/

Testing: tier1 on linux x86_64 and jdk_nio tests. Manual testing of the
fix by looking at the number of open files for the java process running
the reproducer.

Thoughts?

Thanks,
Severin



More information about the nio-dev mailing list