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

SendaoYan syan at openjdk.org
Fri Feb 23 02:00:58 UTC 2024


On Thu, 22 Feb 2024 21:58:51 GMT, Brian Burkhalter <bpb 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.

In the Linux operating system environment, the file operation permissions may be different if the source and target are in different partitions and if the source and target are in the same partition. I am not professional in this area, so this PR is closed.

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

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


More information about the nio-dev mailing list