question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The equals implementation in AbstractCommand is not correct

See original GitHub issue

Here: https://github.com/line/centraldogma/blob/c59d2a1defdb7eda3a27959eca0630fd261034cd/server/src/main/java/com/linecorp/centraldogma/server/command/AbstractCommand.java#L62

It 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:closed
  • Created 10 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ikhooncommented, Nov 14, 2022

I may mention this case in the book if you don’t mind 😃

Absolutely. I’m looking forward to your book! I’d like to read it when it is published. ❤️

0reactions
amaembocommented, Nov 14, 2022

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

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found