Copilot commented on code in PR #13408:
URL: https://github.com/apache/gravitino/pull/13408#discussion_r4069191691


##########
core/src/main/java/org/apache/gravitino/meta/GroupEntity.java:
##########
@@ -169,13 +169,22 @@ public boolean equals(Object o) {
 
   @Override
   public int hashCode() {
-    return Objects.hash(id, name, auditInfo, roleNames, roleIds);
+    // roleNames/roleIds are compared as unordered collections in equals, so 
their
+    // hash contribution must not depend on element order either.
+    int hash = Objects.hash(id, name, namespace, auditInfo);
+    hash = 31 * hash + unorderedHashCode(roleNames);
+    hash = 31 * hash + unorderedHashCode(roleIds);
+    return hash;
   }
 
   public static Builder builder() {
     return new Builder();
   }
 
+  private static int unorderedHashCode(List<?> list) {
+    return list == null ? 0 : list.stream().mapToInt(Object::hashCode).sum();

Review Comment:
   `GroupEntity` permits role lists containing null elements: `Field` validates 
only that the value is a `List`, and `CollectionUtils.isEqualCollection` can 
compare such lists. For a valid entity with a null role, this method throws 
`NullPointerException` instead of returning a hash code, whereas the old 
`List.hashCode()` was null-safe; use `Objects.hashCode` for each element.



-- 
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]

Reply via email to