[
https://issues.apache.org/jira/browse/HADOOP-20068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18138466#comment-18138466
]
ASF GitHub Bot commented on HADOOP-20068:
-----------------------------------------
LuciferYang opened a new pull request, #8932:
URL: https://github.com/apache/hadoop/pull/8932
### Description of PR
JIRA: https://issues.apache.org/jira/browse/HADOOP-20068
`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 an empty
string. `getFileLinkStatus` then reports a live link as a regular file and
throws `FileNotFoundException` for a dangling one, and `getLinkTarget` throws
`is not a symbolic link`. This is the default code path: only
`useStatIfAvailable()` switches it off, and only tests call it. Paths from
`listStatus()` are qualified, and `FileContext` qualifies relative paths, so
both reach it.
This patch uses `pathToFile(f)`, as the rest of the method does. A relative
path now resolves against the file system's working directory instead of the
JVM's current directory, the same as the `getFileStatus(f)` call next to it.
### How was this patch tested?
Added two cases to `TestSymlinkLocalFS`, which run through both the
`FileContext` and the `FileSystem` wrappers, with the deprecated implementation
forced on:
- `testGetLinkStatusQualPathDeprecated`: `getFileLinkStatus` on a qualified
link path reports a symlink with the right target, and `getLinkTarget` returns
the target.
- `testDanglingLinkQualPathDeprecated`: `getFileLinkStatus` on a qualified
dangling link reports a symlink instead of throwing.
Both fail without the fix.
### For code changes:
- [x] Does the title of this PR start with the corresponding JIRA issue id
(e.g. 'HADOOP-17799. Your PR title ...')?
- [ ] Object storage: Have the integration tests been executed and the
endpoint declared according to the connector-specific documentation?
- [ ] If adding new dependencies to the code, are these dependencies
licensed in a way that is compatible for inclusion under [ASF
2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`,
`NOTICE-binary` files?
### AI Tooling
- [x] The PR includes the phrase "Contains content generated by Claude Opus".
- [x] My use of AI contributions follows the ASF legal policy
https://www.apache.org/legal/generative-tooling.html
Contains content generated by Claude Opus.
> 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
>
> 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]