HADOOP-16707. NPE in UGI.getCurrentUser in ITestAbfsIdentityTransformer setup.

Contributed by Steve Loughran.

Change-Id: I38fdba2fa70e534d78b15e61de19368912588b0c
This commit is contained in:
Steve Loughran 2019-11-20 14:32:12 +00:00 committed by GitHub
parent dfc61d8ea5
commit 1415ad3800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -584,6 +584,7 @@ public boolean hasKerberosCredentials() {
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static UserGroupInformation getCurrentUser() throws IOException {
ensureInitialized();
AccessControlContext context = AccessController.getContext();
Subject subject = Subject.getSubject(context);
if (subject == null || subject.getPrincipals(User.class).isEmpty()) {
@ -670,6 +671,7 @@ public static UserGroupInformation getUGIFromSubject(Subject subject)
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static UserGroupInformation getLoginUser() throws IOException {
ensureInitialized();
UserGroupInformation loginUser = loginUserRef.get();
// a potential race condition exists only for the initial creation of
// the login user. there's no need to penalize all subsequent calls