From 5ae5b869aa1be5b878957a5ec288c3dbc28900c3 Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Fri, 6 May 2016 21:50:09 -0700 Subject: [PATCH] YARN-5048. DelegationTokenRenewer#skipTokenRenewal may throw NPE (Jian He via Yongjun Zhang) (cherry picked from commit 47c41e7ac7e6b905a58550f8899f629c1cf8b138) --- .../resourcemanager/security/DelegationTokenRenewer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java index cca14e9472f..fd12f11c789 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java @@ -539,9 +539,14 @@ public class DelegationTokenRenewer extends AbstractService { */ private boolean skipTokenRenewal(Token token) throws IOException { + @SuppressWarnings("unchecked") - Text renewer = ((Token)token). - decodeIdentifier().getRenewer(); + AbstractDelegationTokenIdentifier identifier = + ((Token) token).decodeIdentifier(); + if (identifier == null) { + return false; + } + Text renewer = identifier.getRenewer(); return (renewer != null && renewer.toString().equals("")); }