[
https://issues.apache.org/jira/browse/HADOOP-9364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13595382#comment-13595382
]
Chris Nauroth commented on HADOOP-9364:
---------------------------------------
I think part of the confusion may come from the fact that the patch alone
doesn't provide a lot of context about what is actually happening. To really
understand it, we need to look further down into some of the PathData logic
that is not changing in the patch file:
{code}
// convert stats to PathData
items = new PathData[stats.length];
int i=0;
for (FileStatus stat : stats) {
URI matchUri = stat.getPath().toUri();
String globMatch = null;
switch (globType) {
case HAS_SCHEME: // use as-is, but remove authority if necessary
if (globUri.getAuthority() == null) {
matchUri = removeAuthority(matchUri);
}
globMatch = matchUri.toString();
break;
case SCHEMELESS_ABSOLUTE: // take just the uri's path
globMatch = matchUri.getPath();
break;
case RELATIVE: // make it relative to the current working dir
URI cwdUri = fs.getWorkingDirectory().toUri();
globMatch = relativize(cwdUri, matchUri, stat.isDirectory());
break;
}
items[i++] = new PathData(fs, globMatch, stat);
}
{code}
Here, we see that if the glob type has been identified as RELATIVE, then the
output will be made relative to the current working dir. We really want
SCHEMELESS_ABSOLUTE. As per Ivan's earlier comment, {{File#isAbsolute}} states
that it's a relative path when running on Windows, so it gets mis-classified as
RELATIVE instead of SCHEMELESS_ABSOLUTE. Switching to {{Path}} fixes it,
because we've already invested in getting that code to correctly identify
absolute paths according to the cross-platform rules that we need.
> PathData#expandAsGlob does not return correct results for absolute paths on
> Windows
> -----------------------------------------------------------------------------------
>
> Key: HADOOP-9364
> URL: https://issues.apache.org/jira/browse/HADOOP-9364
> Project: Hadoop Common
> Issue Type: Bug
> Affects Versions: 3.0.0, trunk-win
> Reporter: Ivan Mitic
> Assignee: Ivan Mitic
> Attachments: HADOOP-9364.2.patch,
> HADOOP-9364.branch-trunk-win.pathdata.patch
>
>
> This causes {{FsShell ls}} not to work properly for absolute paths. For
> example:
> {code}
> -fs hdfs://127.0.0.1:58559 -ls -R /dir0
> {code}
> returns
> {code}
> drwxr-xr-x - ivanmi supergroup 0 2013-03-05 11:15 ../../dir0/dir1
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira