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


##########
core/src/main/java/org/apache/gravitino/meta/ModelVersionEntity.java:
##########
@@ -170,13 +170,20 @@ public boolean equals(Object o) {
 
   @Override
   public int hashCode() {
-    return Objects.hash(modelIdent, version, comment, aliases, uris, 
properties, auditInfo);
+    // aliases are compared as an unordered collection in equals, so their hash
+    // contribution must not depend on element order either.
+    int hash = Objects.hash(modelIdent, version, comment, uris, properties, 
auditInfo);
+    return 31 * hash + unorderedHashCode(aliases);
   }
 
   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:
   `equals` permits null alias elements because 
`CollectionUtils.isEqualCollection` supports them and 
`EntityFieldLimits.checkMaxLength` explicitly allows null values, but 
`Object::hashCode` throws for such an alias. A valid entity containing a null 
alias will now fail whenever `hashCode()` is called; use a null-safe element 
hash (for example `Objects.hashCode`) so the implementation remains consistent 
for all values accepted by the builder.



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