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 003a51c14f..d0522a06f7 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 void login() throws LoginException { @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 204f65666a..74130cff19 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 void testKerberosLogin() throws Exception { } finally { if (loginContext != null && loginContext.getSubject() != null - && !loginContext.getSubject().getPrincipals().isEmpty()) { + && !loginContext.getSubject().getPrivateCredentials().isEmpty()) { loginContext.logout(); } }