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

fix: equals and hashcode of several classes #1364

Merged
merged 7 commits into from
Mar 13, 2025

Conversation

chrfwow
Copy link
Contributor

@chrfwow chrfwow commented Mar 6, 2025

This PR

Fixes some of the equals and hashcode methods in the sdk.

Related Issues

Fixes #1362

Notes

I assumed that for the classes I modified, two objects should be equal iff their underlying data is equal. E.g. the class Value. Two distinct Value objects should be equal if they represent the same data:

        Value val1 = new Value(12312312);
        Value val2 = new Value(12312312);
        assertEquals(val1, val2);

Please comment if you think there are more such cases in the sdk, or if I added this behavior somewhere it is not appropriate.

@chrfwow chrfwow requested a review from a team as a code owner March 6, 2025 14:14
Copy link

@glissand0 glissand0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the issue so promptly, appreciate it! 👍


@Test
void unequalMutableStructuresAreNotEqual() {
MutableStructure m1 = new MutableStructure();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment: the MutableStructure tests are in ImmutableStructureTest. Should they be moved into a separate class?

@glissand0
Copy link

Perhaps in a separate PR could we address the toString generation as well? Eg, for MutableStructure it is

public String toString() {return "MutableStructure()";}

@tostring(callSuper = true) generates what we want

@chrfwow chrfwow self-assigned this Mar 7, 2025
chrfwow added 2 commits March 10, 2025 10:55
# Conflicts:
#	src/main/java/dev/openfeature/sdk/ImmutableMetadata.java
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.34%. Comparing base (f8df5fb) to head (5feb3b2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1364      +/-   ##
============================================
+ Coverage     92.80%   93.34%   +0.53%     
- Complexity      468      472       +4     
============================================
  Files            43       43              
  Lines          1126     1127       +1     
  Branches         90       91       +1     
============================================
+ Hits           1045     1052       +7     
+ Misses           53       48       -5     
+ Partials         28       27       -1     
Flag Coverage Δ
unittests 93.34% <100.00%> (+0.53%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrfwow chrfwow requested review from liran2000 and glissand0 March 10, 2025 10:37
@chrfwow chrfwow merged commit 69b571e into open-feature:main Mar 13, 2025
12 checks passed
@chrfwow chrfwow deleted the fix-equals-and-hashcode branch March 13, 2025 07:33
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.

MutableContext / MutableStructure equality bug
4 participants