Browse Source

commit 4d5dd9cfd79c4730c9366df6136a3a7c9b26151d
Author: Devaraj Das <ddas@yahoo-inc.com>
Date: Thu Apr 29 12:51:22 2010 -0700

HDFS:1007 from https://issues.apache.org/jira/secure/attachment/12443223/1007-bugfix.patch

+++ b/YAHOO-CHANGES.txt
+Release 0.20.101.1 - unreleased
+
+ . Fixes NPE in the distcp to do with handling of null Tokens
+ (ddas)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077434 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 years ago
parent
commit
b2e9371d06
1 changed files with 13 additions and 11 deletions
  1. 13 11
      src/mapred/org/apache/hadoop/mapreduce/security/TokenCache.java

+ 13 - 11
src/mapred/org/apache/hadoop/mapreduce/security/TokenCache.java

@@ -141,18 +141,20 @@ public class TokenCache {
         //the initialize method of hftp, called via FileSystem.get() done
         //earlier gets a delegation token
         Token<? extends TokenIdentifier> t = ((HftpFileSystem) fs).getDelegationToken(); 
-        credentials.addToken(new Text(fs_addr), t);
+        if (t != null) {
+          credentials.addToken(new Text(fs_addr), t);
         
-        // in this case port in fs_addr is port for hftp request, but
-        // token's port is for RPC
-        // to find the correct DT we need to know the mapping between Hftp port 
-        // and RPC one. hence this new setting in the conf.
-        URI uri = ((HftpFileSystem) fs).getUri();
-        String key = HftpFileSystem.HFTP_SERVICE_NAME_KEY+
-           SecurityUtil.buildDTServiceName(uri, NameNode.DEFAULT_PORT);
-        conf.set(key, t.getService().toString());
-        LOG.info("GOT dt for " + p + " and stored in conf as " + key + "=" 
-            + t.getService());
+          // in this case port in fs_addr is port for hftp request, but
+          // token's port is for RPC
+          // to find the correct DT we need to know the mapping between Hftp port 
+          // and RPC one. hence this new setting in the conf.
+          URI uri = ((HftpFileSystem) fs).getUri();
+          String key = HftpFileSystem.HFTP_SERVICE_NAME_KEY+
+             SecurityUtil.buildDTServiceName(uri, NameNode.DEFAULT_PORT);
+          conf.set(key, t.getService().toString());
+          LOG.info("GOT dt for " + p + " and stored in conf as " + key + "=" 
+              + t.getService());
+        }
       }
     }
   }