Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HK][SONAR] using equals with hashCode #675

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fgdrf
Copy link
Contributor

@fgdrf fgdrf commented Jan 12, 2022

Change-Id: I15c03a9a0668e55b9f20492e1f2769a53d1ee182
Signed-off-by: Frank Gasdorf fgdrf@users.sourceforge.net

Change-Id: I15c03a9a0668e55b9f20492e1f2769a53d1ee182
Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net>
@fgdrf
Copy link
Contributor Author

fgdrf commented Jan 12, 2022

this fixed sonar finding that classes that override equals() also override hashCode().

@fgdrf fgdrf marked this pull request as draft January 12, 2022 10:21
@fgdrf
Copy link
Contributor Author

fgdrf commented Jan 12, 2022

@sschulz92 investigating if the bahavior of equals changed due to missing check of

        if (!(o instanceof AbstractRenderMetrics)) {
            return false;
        }

which has been replaced by

        if (getClass() != obj.getClass()) {
            return false;
        }

I guess I will add a test-case to verify ..

@sschulz92
Copy link
Contributor

You have changed a missing check? I do not get the point tbh :D

@fgdrf
Copy link
Contributor Author

fgdrf commented Jan 12, 2022

You have changed a missing check? I do not get the point tbh :D

Eclipse allows to generate equals & hashCode using members of the class. the generated equals method change as mentioned and I'd like to check if tow different instances / sub-classes of this Abstract class returned equal=true in the past while the new version would say (different class) that these are not equals anymore.

HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants