RFR: 8264744: (fs) Use file cloning in Linux and macOS versions of FileChannel transfer and Files copy methods [v7]

Brian Burkhalter bpb at openjdk.org
Fri Aug 12 14:53:21 UTC 2022


On Fri, 12 Aug 2022 08:55:14 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:
>> 
>>  - 8264744: Refactor {Bsd,Linux}CopyFile::clone into {Bsd,Linux}FileSystem::clone
>>  - Merge
>>  - 8264744: Remove CloneFile classes; refactor to use {Bsd,Linux}CopyFile
>>  - Merge
>>  - 8264744: Fix typo desintation -> destination
>>  - 8264744: Refactor into UnixCopyFile hierarchy
>>  - Merge
>>  - 8264744: Address review comments aside from refactoring
>>  - 8264744: Refactor into provider+dispatcher to reduce amount of JNI code
>>  - 8264744: (fc, fs) Support file cloning in Unix versions of FileChannel transfer and Files copy methods
>
> src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java line 279:
> 
>> 277:         throws IOException
>> 278:     {
>> 279:         boolean copied = false;
> 
> The "copied" flag is a sign that the copyFile method needs to be refactored to split it into the copy of the contents and the file attributes. Also on first glance, re-opening both the source and destination files after a clone is a bug. We should (where possible) only open the source file for reading and the destination file for writing once.

On macOS it's not possible to clone using file descriptors; paths are required.

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

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


More information about the nio-dev mailing list