Parcourir la source

HADOOP-15143. NPE due to Invalid KerberosTicket in UGI. Contributed by Mukul Kumar Singh.

(cherry picked from commit cb60c05c3aff762c39d7d81df9a7b6e071acb181)
(cherry picked from commit dd1de1ea373a2afa9bd475cccd655b9d74710f42)

Conflicts:
	hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java
Jitendra Pandey il y a 7 ans
Parent
commit
7ca1d96b4f

+ 7 - 3
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java

@@ -1131,9 +1131,13 @@ public class UserGroupInformation {
         Object cred = iter.next();
         if (cred instanceof KerberosTicket) {
           KerberosTicket ticket = (KerberosTicket) cred;
-          if (!ticket.getServer().getName().startsWith("krbtgt")) {
-            LOG.warn("The first kerberos ticket is not TGT"
-                + "(the server principal is {}), remove and destroy it.",
+          if (ticket.isDestroyed() || ticket.getServer() == null) {
+            LOG.warn("Ticket is already destroyed, remove it.");
+            iter.remove();
+          } else if (!ticket.getServer().getName().startsWith("krbtgt")) {
+            LOG.warn(
+                "The first kerberos ticket is not TGT"
+                    + "(the server principal is {}), remove and destroy it.",
                 ticket.getServer());
             iter.remove();
             try {