The equals implementation in AbstractCommand is not correct
See original GitHub issueIt says:
if (!(this instanceof AbstractCommand)) {
return false;
}
This condition is always false, as this
is always AbstractCommand
. It should be instead:
if (!(obj instanceof AbstractCommand)) {
return false;
}
It’s interesting that IntelliJ IDEA tried to warn about this, but the warning was suppressed with @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
. After the fix, the suppression would be unnecessary.
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Overriding the java equals() method - not working?
In Java, the equals() method that is inherited from Object is: public boolean equals(Object other);. In other words, the parameter must be ...
Read more >How to Implement Java's equals Method Correctly - SitePoint
It is determined by a class's equals method and there are a couple of things to be considered for a correct implementation.
Read more >How and Why to Override the equals Method in Java
The reason the equals method in the Object class does reference equality is because it does not know how to do anything else....
Read more >Java equals() and hashCode() - DigitalOcean
Object class equals() method implementation returns true only when both the references are pointing to same object.
Read more >Overriding equals() and hashCode() method in Java and ...
Object compares memory location and only return true if two reference ... 2) If two objects are not equal by equals() method then...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Absolutely. I’m looking forward to your book! I’d like to read it when it is published. ❤️
@ikhoon no, I’m doing some research about static analysis and program mistakes for my book. I may mention this case in the book if you don’t mind 😃