[
https://issues.apache.org/jira/browse/LANG-1499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17130582#comment-17130582
]
Miguel Munoz commented on LANG-1499:
------------------------------------
I've always been uncomfortable with ReflectionEquals for this reason. I have
written my own way of using reflection to generate an equals method that
doesn't have this problem. It also runs faster because it does all the
reflective inspection when the class loads, instead of when equals() is called.
And it has a way to do what EqualsBuilder does, but by using method references.
You can check it out at https://github.com/SwingGuy1024/DogTags
> Equals transitivity is violated in EqualsBuilder
> ------------------------------------------------
>
> Key: LANG-1499
> URL: https://issues.apache.org/jira/browse/LANG-1499
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.builder.*
> Affects Versions: 3.9
> Environment: Ubuntu 18.04
> JDK 1.8.0_221
> Commons Lang 3.9-RC2
> JUnit 5.4
> Reporter: Zhiqiang Zang
> Priority: Major
> Labels: Equals(), EqualsBuilder, transitivity
> Attachments: EqualTransitivityTest2.java, EqualsTransitivityTest.java
>
>
> EqualsBuilder.reflectionEquals() does not hold transitivity when comparing
> two subclasses extending a common superclass. For example:
> Given that both class D and E are subclasses of class C, C == D and C == E
> should imply D == E. However EqualsBuilder.reflectionEquals(D, E) returns
> *false* when both EqualsBuilder.reflectionEquals(C, D) andÂ
> EqualsBuilder.reflectionEquals(C, E) return true.
> A junit test is provided as attachment.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)