hadoop-mapreduce-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Devaraj K (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MAPREDUCE-2317) HadoopArchives throwing NullPointerException while creating hadoop archives (.har files)
Date Wed, 13 Apr 2011 05:13:05 GMT

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

Devaraj K commented on MAPREDUCE-2317:
--------------------------------------

Thanks for reviewing.

@Nicholas: 

{quote} 
is it the same that when parent == null, it should not be added to parents list?
{quote} 

Yes.

If it is unix system, for root dir it will go here and do nothing.
{code:xml} 
    Path root = new Path(Path.SEPARATOR);
    for (int i = 0; i < deepest.depth(); i++) {
      List<Path> parents = new ArrayList<Path>();
      for (Path p: justDirs) {
        if (p.compareTo(root) == 0){
          //don nothing
        }
{code} 
For windows system, when p is windows root dir (i.e. like C: ), it will go in else and parent
will come as null, and causes NullPointerException.
{code:xml}
        else {
          Path parent = p.getParent();
          if (allpaths.containsKey(parent.toString())) {
            HashSet<String> children = allpaths.get(parent.toString());
            children.add(p.getName());
          }
{code} 

> HadoopArchives throwing NullPointerException while creating hadoop archives (.har files)
> ----------------------------------------------------------------------------------------
>
>                 Key: MAPREDUCE-2317
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-2317
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: harchive
>    Affects Versions: 0.20.3
>         Environment: windows
>            Reporter: Devaraj K
>            Assignee: Devaraj K
>            Priority: Minor
>             Fix For: 0.20.3
>
>         Attachments: MAPREDUCE-2317.patch
>
>
> While we are trying to run hadoop archive tool in widows using this way, it is giving
the below exception.
> java org.apache.hadoop.tools.HadoopArchives -archiveName temp.har D:/test/in E:/temp
> {code:xml} 
> java.lang.NullPointerException
> 	at org.apache.hadoop.tools.HadoopArchives.writeTopLevelDirs(HadoopArchives.java:320)
> 	at org.apache.hadoop.tools.HadoopArchives.archive(HadoopArchives.java:386)
> 	at org.apache.hadoop.tools.HadoopArchives.run(HadoopArchives.java:725)
> 	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
> 	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
> 	at org.apache.hadoop.tools.HadoopArchives.main(HadoopArchives.java:739)
> {code} 
> I see the code flow to handle this feature in windows also, 
> {code:title=Path.java|borderStyle=solid}
> /** Returns the parent of a path or null if at root. */
>   public Path getParent() {
>     String path = uri.getPath();
>     int lastSlash = path.lastIndexOf('/');
>     int start = hasWindowsDrive(path, true) ? 3 : 0;
>     if ((path.length() == start) ||               // empty path
>         (lastSlash == start && path.length() == start+1)) { // at root
>       return null;
>     }
>     String parent;
>     if (lastSlash==-1) {
>       parent = CUR_DIR;
>     } else {
>       int end = hasWindowsDrive(path, true) ? 3 : 0;
>       parent = path.substring(0, lastSlash==end?end+1:lastSlash);
>     }
>     return new Path(uri.getScheme(), uri.getAuthority(), parent);
>   }
> {code} 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message