RFR: 8321561: (fs) Add an API note to Files.move clarifying possible non-atomic behavior

Alan Bateman alanb at openjdk.org
Thu Jan 11 14:57:23 UTC 2024


On Mon, 11 Dec 2023 16:29:26 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Make it clear that a `FileAlreadyExistsException` may be thrown by `Files.move` even if the `REPLACE_EXISTING` option is specified.

src/java.base/share/classes/java/nio/file/Files.java line 1400:

> 1398:      * copying or renaming, then a {@code FileAlreadyExistsException} may be
> 1399:      * thrown despite the {@code REPLACE_EXISTING} option having been specified.
> 1400:      *

I wonder if it might be better expand the description of REPLACE_EXISTING. That is, the existing paragraph could be expanded to say that if ATOMIC_MOVE is not specified then the checking the check for an existing file and the move is not atomic with respect to other filesystem activities.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17061#discussion_r1448982986


More information about the nio-dev mailing list