RFR: 8293122: (fs) Use file cloning in macOS version of Files::copy method [v3]

Alan Bateman alanb at openjdk.org
Sat Sep 10 14:12:44 UTC 2022


On Fri, 9 Sep 2022 19:39:37 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Use BSD system call `clonefile` if possible when using `Files::copy` on macOS.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8293122: remove volatile cloneFileNotSupported; unlink target on failure; remove getattrlist

src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java line 100:

> 98:             try {
> 99:                 unlink(dst);
> 100:             } catch (UnixException ignore) { }

My previous comment about the missing unlink was a comment on BsdFileSystem.copyFile where it will leave dst in place when the chown fails. The unlink you've added to clone is harmless but the right place is copyFile so that it attempts to cleanup/unlink when an exception is thrown.

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

PR: https://git.openjdk.org/jdk/pull/10188


More information about the nio-dev mailing list