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 dafa1c1ea6..204f65666a 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 @@ -165,7 +165,8 @@ public void testKerberosLogin() throws Exception { loginContext.logout(); } finally { - if (loginContext != null) { + if (loginContext != null && loginContext.getSubject() != null + && !loginContext.getSubject().getPrincipals().isEmpty()) { loginContext.logout(); } }