RFR: 8280881: (fs) UnixNativeDispatcher.close0 may throw UnixException
Jaikiran Pai
jpai at openjdk.java.net
Tue Feb 15 04:31:13 UTC 2022
On Mon, 14 Feb 2022 21:21:14 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.
src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java line 438:
> 436: UnixNativeDispatcher.close(dfd1);
> 437: } catch (UnixException y) {
> 438: x.addSuppressed(y);
Hello Brian,
I think, even after adding this as suppressed exception, this (suprressed) exception will be "lost" because at the end of this outer catch block there's this code:
x.rethrowAsIOException(dir);
and the implementation of `rethrowAsIOException` internally just creates a new exception instance (depending on the error code) but doesn't capture any suppressed exceptions from the original `x`.
src/java.base/unix/classes/sun/nio/fs/UnixSecureDirectoryStream.java line 128:
> 126: UnixNativeDispatcher.close(newdfd1);
> 127: } catch (UnixException e) {
> 128: x.addSuppressed(e);
Same here with respect to suppressed exception and what happens at the end of this catch block with `x.rethrowAsIOException(file);`
-------------
PR: https://git.openjdk.java.net/jdk/pull/7467
More information about the nio-dev
mailing list