[ 
https://issues.apache.org/jira/browse/ARTEMIS-4736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17839792#comment-17839792
 ] 

Justin Bertram commented on ARTEMIS-4736:
-----------------------------------------

bq. ...it compares objects by their classes using the getClass() method...

The comparison using {{getClass()}} doesn't prove equality. It simply proves 
inequality. In other words, if a {{ConnectionFactoryProperties}} instance is 
compared to a {{String}} instance then this comparison would fail (correctly). 
However, if a {{ConnectionFactoryProperties}} instance is compared to another 
{{ConnectionFactoryProperties}} instance then the comparison would succeed and 
the method would *continue executing* rather than just returning {{true}} as is 
implied in your description.

bq. For the equals method to work correctly, you need to override its logic so 
that it compares objects by their fields or other criteria, and not just by 
their classes.

That's exactly what the {{equals}} implementation of 
{{ConnectionFactoryProperties}} does.

> DOESNT OVERRIDE EQUALS in ConnectionFactoryProperties.java
> ----------------------------------------------------------
>
>                 Key: ARTEMIS-4736
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4736
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Galkin Alexey
>            Priority: Major
>
> The class overrides the equals method, but does not implement its logic. 
> Instead, it compares objects by their classes using the getClass() method (
> if (getClass() != obj.getClass()) [line 
> 748|https://github.com/apache/activemq-artemis/blob/main/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java]),
>  which can lead to incorrect object comparisons. For the equals method to 
> work correctly, you need to override its logic so that it compares objects by 
> their fields or other criteria, and not just by their classes.
>  
> Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
> Author Alexey Galkin.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to