RFR: 8324811: java/nio/file/Files/CopyMoveVariations.java fails run with non-root user

Brian Burkhalter bpb at openjdk.org
Thu Feb 22 22:01:54 UTC 2024


On Thu, 22 Feb 2024 15:11:35 GMT, SendaoYan <syan at openjdk.org> wrote:

> This testcase include 3 `Files.move(source, target, options` operations(line 195, line 212, line 232), only the line 195 miss `try catch AccessDeniedException` surround.

This is because `AccessDeniedException` is not expected. For a file move operation there is no permission requirement unless the source is a directory, in which case it must be writable.

> And for the line 219, when there is a `AccessDeniedException`, then the source file should miss read permission, so `mode.charAt(1) != 'r'` , rather than `mode.charAt(1) != 'w'`.

The modes are defined by

 99             String[] modes = new String[] {
100                 "---------", "r--r--r--", "-w--w--w-", "rw-rw-rw-"
101             };

so I do not see how `mode.charAt(1)` could ever return `r`. Anyway, as a directory and not a file is being moved, the requirement is that the source directory be wrotable so `w` is correct.

> So, it seems that it's a testcase bug cause this testcase run fail at some situation.

As previously mentioned, we have not seen this in any reasonable scenario.

> Maybe this PR is more reasonable than #17235

Actually I think #17235 is more reasonable and that this PR should be withdrawn.

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

PR Comment: https://git.openjdk.org/jdk/pull/17606#issuecomment-1960386141


More information about the nio-dev mailing list