[ 
https://issues.apache.org/jira/browse/HADOOP-20068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140469#comment-18140469
 ] 

ASF GitHub Bot commented on HADOOP-20068:
-----------------------------------------

slfan1989 commented on code in PR #8932:
URL: https://github.com/apache/hadoop/pull/8932#discussion_r4504640732


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/RawLocalFileSystem.java:
##########
@@ -1330,7 +1330,7 @@ private FileStatus getFileLinkStatusInternal(final Path f,
   @Deprecated
   private FileStatus deprecatedGetFileLinkStatusInternal(final Path f)
       throws IOException {
-    String target = FileUtil.readLink(new File(f.toString()));
+    String target = FileUtil.readLink(pathToFile(f));

Review Comment:
   Could we also qualify the link path stored in the returned `FileStatus`? 
   
   With the filesystem working directory set to a temp directory containing 
`link -> target`, I reproduced an `IllegalArgumentException` from 
`getFileLinkStatus(new Path("link"))`.
   
   `pathToFile(f)` finds the link, but the status still carries the relative 
path link, so qualifying the relative target fails. 
   
   Could we use `makeQualified(f)` in both symlink return paths and add a 
regression test?





> RawLocalFileSystem#getFileLinkStatus and #getLinkTarget miss symlinks when 
> given a qualified file: path
> -------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-20068
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20068
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>            Reporter: Yang Jie
>            Priority: Minor
>              Labels: pull-request-available
>
> deprecatedGetFileLinkStatusInternal locates the link with {{new 
> File(f.toString())}}. For a qualified path such as file:/tmp/link that is a 
> relative file named "file:/tmp/link", so FileUtil.readLink() returns "" and:
> * getFileLinkStatus(file:/tmp/link) on a live link returns the target's 
> status with isSymlink() false;
> * on a dangling link it throws FileNotFoundException;
> * getLinkTarget(file:/tmp/link) throws "Path ... is not a symbolic link".
> This is the code path RawLocalFileSystem uses by default: 
> {{useDeprecatedFileStatus}} is only turned off by useStatIfAvailable(), which 
> is called only from tests. Paths returned by listStatus() are qualified, and 
> FileContext qualifies relative paths, so both reach it. The {{new 
> File(f.toString())}} came in with HADOOP-9527.
> The fix uses pathToFile(f), which is how the rest of the method and the class 
> locate files.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to