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

Alan Bateman alanb at openjdk.org
Fri Sep 13 07:22:05 UTC 2024


On Fri, 13 Sep 2024 07:00:24 GMT, xpbob <duke at openjdk.org> wrote:

> (fs) Files.copy include symbolic link detailed message for NoSuchFileException
> 
> Description
> Simulation case:
> 
> touch testfile
> ln -s testfile testlink
> mv testfile testfile1
> 
> 
> code:
> 
>     public static void main(String[] args) throws IOException {
>         Files.copy(Paths.get("/data/testfiles/testlink"), Paths.get("/data/testfiles/xx"));
>     }
> 
> 
> Program current information:
> Exception in thread "main" java.nio.file.NoSuchFileException: /data/testfiles/testlink
> 
> 
> Devops check file exists with ll
> 
> After additional information:
> Exception in thread "main" java.nio.file.NoSuchFileException: /data/testfiles/testlink: due to testfile

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.

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

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


More information about the nio-dev mailing list