RFR: 8293122: (fs) Use file cloning in macOS version of Files::copy method [v4]
Alan Bateman
alanb at openjdk.org
Tue Sep 13 11:09:44 UTC 2022
On Mon, 12 Sep 2022 16:22:39 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: Move rollback unlink to copyFile method
src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java line 128:
> 126: // Attempt to clone the source unless cancellation is not possible,
> 127: // or attributes are not to be copied
> 128: if (addressToPollForCancel == 0 && flags.copyPosixAttributes) {
It wouldn't be wrong to the check for copyPosixAttributes here, in which case they would be copied by default (the spec allows for that). The only issue is that someone might become dependent on this and then be surprised when they code behaves differently when run on another platform.
I'm curious if there is a way to test how clone behaves when it fails. What you have is okay although the unlink might only be needed when chown fails.
-------------
PR: https://git.openjdk.org/jdk/pull/10188
More information about the nio-dev
mailing list