yuqi1129 commented on code in PR #3852:
URL: https://github.com/apache/gravitino/pull/3852#discussion_r1679224887
##########
core/src/main/java/org/apache/gravitino/utils/PrincipalUtils.java:
##########
@@ -47,10 +47,19 @@ public static <T> T doAs(Principal principal,
PrivilegedExceptionAction<T> actio
public static Principal getCurrentPrincipal() {
java.security.AccessControlContext context =
java.security.AccessController.getContext();
Subject subject = Subject.getSubject(context);
- if (subject == null ||
subject.getPrincipals(UserPrincipal.class).isEmpty()) {
+ if (subject == null) {
return new UserPrincipal(AuthConstants.ANONYMOUS_USER);
}
- return subject.getPrincipals(UserPrincipal.class).iterator().next();
+
+ if (!subject.getPrincipals(UserPrincipal.class).isEmpty()) {
+ return subject.getPrincipals(UserPrincipal.class).iterator().next();
+ }
+
+ if (!subject.getPrincipals().isEmpty()) {
+ return new
UserPrincipal(subject.getPrincipals().iterator().next().getName());
Review Comment:
I think we'd better add some description that `PrincipalUtils` can't only be
used in nested `doAs` code block if without this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]