HADOOP-8751. NPE in Token.toString() when Token is constructed using null identifier. Contributed by kanaka kumar avvaru.
(cherry picked from commit 56996a685e
)
This commit is contained in:
parent
84245ff3b2
commit
70615947bd
|
@ -287,6 +287,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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue