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

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   `RemoveMetadataObject.equals` casts its argument to the sibling class 
`RenameMetadataObject` after the `getClass()` guard, so comparing two 
`RemoveMetadataObject` instances (directly, or through `HashSet.contains`) 
always throws `ClassCastException`. It also ignores `locations`, unlike 
`RenameMetadataObject.equals`.
   
   ### Error message and/or stacktrace
   
   `java.lang.ClassCastException` is thrown from `RemoveMetadataObject.equals` 
when the argument is another `RemoveMetadataObject`, because the value is cast 
to `RenameMetadataObject`.
   
   ### How to reproduce
   
   Create two `MetadataObjectChange.RemoveMetadataObject` instances and call 
`equals` on them, or add one to a `HashSet` and call `contains`; the call 
throws `ClassCastException`.
   
   ### Additional context
   
   The sibling `RenameMetadataObject.equals` compares both `metadataObject` and 
`locations`, and `RemoveMetadataObject` should match that contract. Found 
during a review of the `api` module.
   


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