From fea16a440d195f1b4e03a62c9249e3518cea23b5 Mon Sep 17 00:00:00 2001 From: Takanobu Asanuma Date: Wed, 14 Mar 2018 13:38:07 +0900 Subject: [PATCH] HADOOP-15294. TestUGILoginFromKeytab fails on Java9 Signed-off-by: Akira Ajisaka --- .../org/apache/hadoop/security/UserGroupInformation.java | 5 ++++- .../src/test/java/org/apache/hadoop/minikdc/TestMiniKdc.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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(); } }