diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java index 003a51c14ff..d0522a06f77 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java @@ -1885,7 +1885,10 @@ public class UserGroupInformation { @Override public void logout() throws LoginException { synchronized(getSubjectLock()) { - super.logout(); + if (this.getSubject() != null + && !this.getSubject().getPrivateCredentials().isEmpty()) { + super.logout(); + } } } } diff --git a/hadoop-common-project/hadoop-minikdc/src/test/java/org/apache/hadoop/minikdc/TestMiniKdc.java b/hadoop-common-project/hadoop-minikdc/src/test/java/org/apache/hadoop/minikdc/TestMiniKdc.java index 204f65666a7..74130cff19b 100644 --- a/hadoop-common-project/hadoop-minikdc/src/test/java/org/apache/hadoop/minikdc/TestMiniKdc.java +++ b/hadoop-common-project/hadoop-minikdc/src/test/java/org/apache/hadoop/minikdc/TestMiniKdc.java @@ -166,7 +166,7 @@ public class TestMiniKdc extends KerberosSecurityTestcase { } finally { if (loginContext != null && loginContext.getSubject() != null - && !loginContext.getSubject().getPrincipals().isEmpty()) { + && !loginContext.getSubject().getPrivateCredentials().isEmpty()) { loginContext.logout(); } }