RFR: 8073061: (fs) Files.copy(foo, bar, REPLACE_EXISTING) deletes bar even if foo is not readable [v3]

Alan Bateman alanb at openjdk.org
Thu Sep 7 16:18:43 UTC 2023


On Thu, 7 Sep 2023 16:12:20 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 920:
>> 
>>> 918:                 // ensure source can be moved
>>> 919:                 try {
>>> 920:                     access(source, R_OK|W_OK);
>> 
>> I wonder this should be changed to R_OK and done after the rename attempt has failed. I think that would make it consistent with the copy case (as move falls back to a copy when rename fails).
>
> But the existing target would be deleted after line 928 before rename() is called.

Okay, you're right but I'm not 100% sure that the mode is right, I assumed it would be R_OK.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15501#discussion_r1318846345


More information about the nio-dev mailing list