You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Davies Liu (JIRA)" <ji...@apache.org> on 2016/08/10 22:35:20 UTC

[jira] [Commented] (HADOOP-12455) fs.Globber breaks on colon in filename; doesn't use Path's handling for colons

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

Davies Liu commented on HADOOP-12455:
-------------------------------------

I think the root cause is that `fs.Path` try to parse `A` in `A:B` as schema, but it does not support schema with relative path, so it does not make sense. I think the schema should always be followed by `/` (at least for Hadoop), we could patch fs.Path
from 
{code}
    // parse uri scheme, if any
    int colon = pathString.indexOf(':');
    int slash = pathString.indexOf('/');
    if ((colon != -1) &&
        ((slash == -1) || (colon < slash))) {     // has a scheme
      scheme = pathString.substring(0, colon);
      start = colon+1;
    }
{code}
to 
{code}
    // parse uri scheme, if any
    int colon = pathString.indexOf(':');
    int slash = pathString.indexOf('/');
    if ((colon != -1) && slash == colon + 1) {     // has a scheme
      scheme = pathString.substring(0, colon);
      start = colon+1;
    }
{code}

> fs.Globber breaks on colon in filename; doesn't use Path's handling for colons
> ------------------------------------------------------------------------------
>
>                 Key: HADOOP-12455
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12455
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>            Reporter: Daniel Barclay
>            Assignee: Rich Haase
>              Labels: trivial
>             Fix For: 2.9.0
>
>         Attachments: HADOOP-12455.patch
>
>
> {{org.apache.hadoop.fs.Globber.glob()}} breaks when a searched directory 
> contains a file whose simple name contains a colon.
> The problem seem to be in the code currently at lines 258 and 257 
> [https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Globber.java#L257]:
> {noformat}
> 256:              // Set the child path based on the parent path.
> 257:              child.setPath(new Path(candidate.getPath(),
> 258:                      child.getPath().getName()));
> {noformat}
> That last line should probably be:
> {noformat}
>                       new Path(null, null, child.getPath().getName())));
> {noformat}
> &nbsp;
> The bug in the current code is that:
> 1) {{child.getPath().getName()}} gets the simple name (last segment) of the child {{Path}} as a _raw_ string (not necessarily the corresponding relative _{{Path}}_ string), and
> 2) that raw string is passed as {{Path(Path, String)}}'s second argument, which takes a _{{Path}}_ string.
> When that raw string contains a colon (e.g., {{xxx:yyy}}), it looks like a {{Path}} string that specifies a scheme ("{{xxx}}") and has a relative path "{{yyy}}}"--but that combination isn't allowed, so trying to constructing a {{Path}} with it (as {{Path(Path, String)}} does inside) throws an exception, aborting the entire {{glob()}} call.
> &nbsp;
> Adding the call to {{Path(String, String, String)}} does the equivalent of converting the raw string "{{xxx:yyy}}" to the {{Path}} string "{{./xxx:yyy}}", so the part before the colon is not taken as a scheme.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org