lasdf1234 commented on code in PR #10503:
URL: https://github.com/apache/gravitino/pull/10503#discussion_r2972688003
##########
core/src/main/java/org/apache/gravitino/UserPrincipal.java:
##########
@@ -47,25 +66,34 @@ public String getName() {
return username;
}
+ /**
+ * Returns the groups of this principal.
+ *
+ * @return the groups
+ */
+ public List<String> getGroups() {
+ return groups;
+ }
+
@Override
public int hashCode() {
- return username.hashCode();
+ return Objects.hash(username, groups);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
- if (o instanceof UserPrincipal) {
- UserPrincipal that = (UserPrincipal) o;
- return this.username.equals(that.username);
+ if (!(o instanceof UserPrincipal)) {
+ return false;
}
- return false;
+ UserPrincipal that = (UserPrincipal) o;
+ return Objects.equals(username, that.username) && Objects.equals(groups,
that.groups);
}
Review Comment:
The code above modifies the equals method to determine whether the username
attribute and the groups attribute are consistent.
--
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]