From 19287eeeb2c10ea5562c2fe43d8bd16814ddf8dd Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 17 Jan 2024 16:34:33 +0000 Subject: [PATCH] 8321561: (fs) Clarify non-atomic behavior of Files.move Reviewed-by: alanb --- src/java.base/share/classes/java/nio/file/Files.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/nio/file/Files.java b/src/java.base/share/classes/java/nio/file/Files.java index 82ab732aec4..cc35012fa0a 100644 --- a/src/java.base/share/classes/java/nio/file/Files.java +++ b/src/java.base/share/classes/java/nio/file/Files.java @@ -1359,6 +1359,9 @@ public final class Files { * associated with a different provider to this object. * * + * If the {@code ATOMIC_MOVE} option is not specified, then the check + * whether the target file exists and the actual move might not be atomic + * with respect to other filesystem activities. * *

An implementation of this interface may support additional * implementation specific options. @@ -1404,8 +1407,11 @@ public final class Files { * if the array contains a copy option that is not supported * @throws FileAlreadyExistsException * if the target file exists but cannot be replaced because the - * {@code REPLACE_EXISTING} option is not specified (optional - * specific exception) + * {@code REPLACE_EXISTING} option is not specified. + * It may also be thrown when the {@code REPLACE_EXISTING} option + * is specified, the move is not atomic, and the target + * file is created by some other entity at around the same time + * that this method is called * @throws DirectoryNotEmptyException * the {@code REPLACE_EXISTING} option is specified but the file * cannot be replaced because it is a non-empty directory, or the