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

Alan Bateman alanb at openjdk.org
Thu Aug 31 19:36:59 UTC 2023


On Thu, 31 Aug 2023 00:18:22 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Check that the source is readable before deleting the destination.

src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 919:

> 917:             } else if (!sourceAttrs.isSymbolicLink() || flags.followLinks) {
> 918:                 // Ensure source can be read
> 919:                 provider.checkAccess(source, AccessMode.READ);

I don't think this will work with a SM set as that will trigger a check that the SM will allow read before it checks if there is read access at the file system level (move is specified to check the SM for write access to both source and target).

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

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


More information about the nio-dev mailing list