hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject hadoop git commit: HADOOP-8751. NPE in Token.toString() when Token is constructed using null identifier. Contributed by kanaka kumar avvaru.
Date Tue, 26 May 2015 07:18:43 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 39077dba2 -> 56996a685


HADOOP-8751. NPE in Token.toString() when Token is constructed using null identifier. Contributed
by kanaka kumar avvaru.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/56996a68
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/56996a68
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/56996a68

Branch: refs/heads/trunk
Commit: 56996a685e6201cb186cea866d22418289174574
Parents: 39077db
Author: Akira Ajisaka <aajisaka@apache.org>
Authored: Tue May 26 16:16:21 2015 +0900
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Tue May 26 16:16:21 2015 +0900

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt      |  3 +++
 .../java/org/apache/hadoop/security/token/Token.java |  8 ++++----
 .../token/delegation/TestDelegationToken.java        | 15 +++++++++++++++
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/56996a68/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 48be07a..864865f 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -752,6 +752,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-11927.  Fix "undefined reference to dlopen" error when compiling
     libhadooppipes (Xianyin Xin via Colin P. McCabe)
 
+    HADOOP-8751. NPE in Token.toString() when Token is constructed using null
+    identifier. (kanaka kumar avvaru via aajisaka)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/56996a68/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
index 32a8cd3..bd254e6 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
@@ -70,10 +70,10 @@ public class Token<T extends TokenIdentifier> implements Writable
{
    * @param service the service for this token
    */
   public Token(byte[] identifier, byte[] password, Text kind, Text service) {
-    this.identifier = identifier;
-    this.password = password;
-    this.kind = kind;
-    this.service = service;
+    this.identifier = (identifier == null)? new byte[0] : identifier;
+    this.password = (password == null)? new byte[0] : password;
+    this.kind = (kind == null)? new Text() : kind;
+    this.service = (service == null)? new Text() : service;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/56996a68/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java
index 239b841..b41ff15 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java
@@ -44,6 +44,7 @@ import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
 import org.apache.hadoop.security.token.SecretManager;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.SecretManager.InvalidToken;
+import org.apache.hadoop.security.token.TokenIdentifier;
 import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation;
 import org.apache.hadoop.util.Daemon;
 import org.apache.hadoop.util.Time;
@@ -539,4 +540,18 @@ public class TestDelegationToken {
     Assert.assertEquals(key1, key2);
     Assert.assertFalse(key2.equals(key3));
   }
+
+  @Test
+  public void testEmptyToken() throws IOException {
+    Token<?> token1 = new Token<TokenIdentifier>();
+
+    Token<?> token2 = new Token<TokenIdentifier>(new byte[0], new byte[0],
+        new Text(), new Text());
+    assertEquals(token1, token2);
+    assertEquals(token1.encodeToUrlString(), token2.encodeToUrlString());
+
+    token2 = new Token<TokenIdentifier>(null, null, null, null);
+    assertEquals(token1, token2);
+    assertEquals(token1.encodeToUrlString(), token2.encodeToUrlString());
+  }
 }


Mime
View raw message