RFR: 8340087: (fs) Files.copy include symbolic link detailed message for NoSuchFileException [v2]

Brian Burkhalter bpb at openjdk.org
Fri Sep 13 16:19:06 UTC 2024


On Fri, 13 Sep 2024 08:49:22 GMT, xpbob <duke at openjdk.org> wrote:

>> 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);
> ……

> The default provider implementation can't use Files.* methods, otherwise you end up with recursive usage.

`UnixFileSystemProvider` is what I think ought to be used instead.

> In any case, I think the starting out to decide if anything should change as the existing NoSuchFileException is not wrong.

Please see [2. Socialize your change](https://openjdk.org/guide/#socialize-your-change).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20984#discussion_r1759138049


More information about the nio-dev mailing list