RFR: 8340087: (fs) Files.copy include symbolic link detailed message for NoSuchFileException [v2]
xpbob
duke at openjdk.org
Fri Sep 13 08:54:20 UTC 2024
On Fri, 13 Sep 2024 07:19:11 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> xpbob has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Reimport package
>
> src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 1013:
>
>> 1011: if (symbolicLink != null) {
>> 1012: throw new NoSuchFileException(source.toString(), null, "due to " + symbolicLink);
>> 1013: }
>
> The default provider implementation can't use Files.* methods, otherwise you end up with recursive usage.
>
> In any case, I think the starting out to decide if anything should change as the existing NoSuchFileException is not wrong.
Thanks for review
@AlanBateman
The NoSuchFileException in this case is correct,The code is to add contextual information for NoSuchFileException.
In this case, the symlinked file does not exist, the symlink exist.
NoSuchFileException info is symlink.
`ls path to symlink` The detection file exists.This is supposed to detect the symlinked file.Expect to add symbolic link information in the NoSuchFileException
before
Exception in thread "main" java.nio.file.NoSuchFileException: /data/testfiles/testlink
after
Exception in thread "main" java.nio.file.NoSuchFileException: /data/testfiles/testlink: due to testfile
The condition for throwing a NoSuchFileException has not changed
private IOException translateToIOException(String file, String other) {
……
if (errno() == UnixConstants.ENOENT)
return new NoSuchFileException(file, other, null);
……
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20984#discussion_r1758459486
More information about the nio-dev
mailing list