RFR: 8317128: java/nio/file/Files/CopyAndMove.java failed with AccessDeniedException

Alan Bateman alanb at openjdk.org
Sat Sep 30 06:27:39 UTC 2023


On Fri, 29 Sep 2023 15:57:48 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> The change #15501 removed explicit throwing of a `FileAlreadyExistsException` in `copyToForeignTarget` for non-directories when the target exists and `REPLACE_EXISTING` is not specified, instead relying on `FileChannel.open` eventually to throw this exception. The test, however, reuses the same file path, and on Windows `CreateFile`, which is invoked by `open`, can throw an `AccessDeniedException` if the file exists and has been marked for deletion but not yet actually deleted. This change proposes to reinstate explicitly throwing a FAEE.

src/java.base/share/classes/java/nio/file/CopyMoveHelper.java line 150:

> 148:             Files.createDirectory(target);
> 149:         } else {
> 150:             try (InputStream in = Files.newInputStream(source)) {

If we are you reverting that then I assume you also should revert the change to L147 too, meaning replaceExistingOrEmpty() isn't needed now.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15991#discussion_r1341917792


More information about the nio-dev mailing list