LuciferYang opened a new pull request, #13408:
URL: https://github.com/apache/gravitino/pull/13408

   ### What changes were proposed in this pull request?
   
   `GroupEntity.hashCode` now combines an order-independent sum of element 
hashes for `roleNames` and `roleIds` with the scalar fields, matching exactly 
what `equals` compares. It also folds in `namespace`, which `equals` already 
compared but the old `hashCode` omitted.
   
   ### Why are the changes needed?
   
   `equals` compares `roleNames` and `roleIds` order-independently via 
`CollectionUtils.isEqualCollection`, but `hashCode` hashed the `List`s 
directly, so two equal groups with different role ordering hashed differently, 
breaking the `Object.hashCode` contract for any hash-based collection.
   
   Fix: #13407
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added `TestGroupEntity.testHashCodeConsistentWithBagEquality`, which pins 
that two groups equal under unordered role collections share a hash code. It 
fails against the pre-fix code.
   


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