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

Langer, Christoph christoph.langer at sap.com
Wed Oct 9 07:20:11 UTC 2019


Hi,

the patch looks good to me, too.

I'm wondering, though, whether StreamEncoder::implClose shouldn't be made more resilient?

E.g. when writeBytes() fails at [0], shouldn't still a close on ch or out be attempted? Maybe under a separate bug?

Best regards
Christoph

[0] http://hg.openjdk.java.net/jdk/jdk/file/eb68d459ba6a/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java#l346


> -----Original Message-----
> From: nio-dev <nio-dev-bounces at openjdk.java.net> On Behalf Of Alan
> Bateman
> Sent: Dienstag, 8. Oktober 2019 19:43
> To: Severin Gehwolf <sgehwolf at redhat.com>; nio-dev at openjdk.java.net
> Subject: Re: RFR: 8232003: (fs) Files.write can leak file descriptor in the
> exception case
> 
> 
> 
> On 08/10/2019 18:02, Severin Gehwolf wrote:
> > 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.
> NFS is the other scenario where close fails as the buffered bytes cannot
> be flushed to the server. The patch looks good.
> 
> -Alan


More information about the nio-dev mailing list