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

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

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


##########
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:
   Done. Both symlink returns in `deprecatedGetFileLinkStatusInternal` now use 
`makeQualified(f)`, which matches the path Stat returns. Added 
`testGetLinkStatusRelPathDeprecated` to `TestSymlinkLocalFSFileSystem`: with 
the working directory set, it calls `getFileLinkStatus` on relative paths to a 
link and to a dangling link, both with relative targets. Without the fix it 
fails with that `IllegalArgumentException`.





> 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