RFR: 8280881: (fs) UnixNativeDispatcher.close0 may throw UnixException [v5]

Alan Bateman alanb at openjdk.java.net
Fri Feb 25 20:05:01 UTC 2022


On Fri, 25 Feb 2022 17:39:07 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Re-specify `sun.nio.fs.UnixNativeDispatcher.close0()` to throw `sun.nio.fs.UnixException` and modify callers either to ignore it or to rethrow it as an `IOException`, as appropriate.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8280881: Suppress some uninteresting exceptions

I think it's improving but I think can be simplified.

src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java line 74:

> 72:         } catch (UnixException x) {
> 73:             throw UnixNativeDispatcher.close(ifd,
> 74:                 new IOException(x.errorString()), e -> null);

If socketpair fails then I'm not sure it's worth trying to report the failure of ifd too. I think I would change this to

close(ifd, e -> null)
throw new IOException(x.errorString());

src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java line 441:

> 439:             if (dfd2 != -1)
> 440:                 ioe = UnixNativeDispatcher.close(dfd2, ioe, e -> null);
> 441:             throw ioe;

I think it would be simpler to just revert the change and just call close(dfd1, e -> null) and close(dfd2, e -> null).

src/java.base/unix/classes/sun/nio/fs/UnixSecureDirectoryStream.java line 126:

> 124:                     ioe = UnixNativeDispatcher.close(newdfd1, ioe, e -> null);
> 125:                 if (newdfd2 != -1)
> 126:                     ioe = UnixNativeDispatcher.close(newdfd1, ioe, e -> null);

Same comment as UnixFileSystemProvider.

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

PR: https://git.openjdk.java.net/jdk/pull/7467


More information about the nio-dev mailing list