LuciferYang opened a new issue, #13421:
URL: https://github.com/apache/gravitino/issues/13421

   **What would you like to be improved?**
   
   Several core entities compare a collection field with 
`CollectionUtils.isEqualCollection` (bag semantics, order-independent) in 
`equals`, but their `hashCode` hashes the `List` directly, which is 
order-sensitive:
   
   - `GroupEntity` and `UserEntity`: `roleNames`, `roleIds`
   - `ModelVersionEntity`: `aliases`
   - `RoleEntity`: `securableObjects`
   - `TableEntity`: `columns`
   
   Two entities that are equal under `equals` but differ only in element order 
get different hash codes, which violates the `Object.hashCode` contract and 
loses them in any `HashSet` or `HashMap`.
   
   **How should we improve?**
   
   Add an order-independent, null-safe helper next to 
`CollectionUtils.isEqualCollection` and use it from all five entities, so 
`equals` and `hashCode` share one collection helper. `GroupEntity` and 
`UserEntity` also fold in `namespace`, which `equals` already compares, and 
`TableEntity` drops an accidentally duplicated `distribution` argument.
   


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