-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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 role descriptor's hashCode, equals and isEmpty implementations #108255
Merged
elasticsearchmachine
merged 10 commits into
elastic:main
from
slobodanadamovic:sa-fix-role-descriptor-equals-hashcode-isempty
May 6, 2024
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1d99618
Fix role descriptor's hashCode, equals and isEmpty implementations
slobodanadamovic 326e80b
Remove `remoteClusterAliasMatcher` from equals and hashCode
slobodanadamovic 9304367
Merge branch 'main' of github.com:elastic/elasticsearch into sa-fix-r…
slobodanadamovic e643374
Remove equals and hashCode from StringMatcher
slobodanadamovic 6c0dd74
Explain why we omit remoteClusterAliasMatcher
slobodanadamovic 6768967
Merge branch 'main' of github.com:elastic/elasticsearch into sa-fix-r…
slobodanadamovic bc6f77a
Merge branch 'main' of github.com:elastic/elasticsearch into sa-fix-r…
slobodanadamovic a75639f
Unmute GetUserPrivilegesResponseTests.testSerializationForCurrentVersion
slobodanadamovic 0e2892d
drop the long comment
slobodanadamovic a682b89
Merge branch 'main' of github.com:elastic/elasticsearch into sa-fix-r…
slobodanadamovic File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to remove
remoteClusterAliasMatcher
from both hashCode and equals implementation as it is always wrong due to the nature ofPredicate
. I'm thinking of not overriding them inStringMatcher
to avoid confusion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird ... the unit tests extend AbstractXContentSerializingTestCase which in turn tests org.elasticsearch.test.AbstractWireTestCase#testConcurrentEquals.. which should catch things like that.
Taking a deeper look and adding this test:
So those equality tests passed since i guess '*' is a special case.
I explicitly added the equals/hash to StringMatcher for this purpose (but only relied on tests from AbstractXContentSerializingTestCase of RemoteClusterPermissionGroup). Can you also remove the equals and hash code, or better update them to always return false with a comment to why (that is super trappy behavior).
Also, can you add a comment we explicitly omit the matcher ? It doesn't need be there and the only reason I included it in the equality was to avoid messages like this since most devs will just let the IDE generate these.
Also thanks for fixing the missing RoleDescriptor equality. I just ran the failing RoleDescriptor test a 1000 times and it only failed 3/1000 of the times (and got it to pass with 0/1000 failures) . We really shouldn't use that much randomization :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning false would be wrong when the same object is compared. So I decided to remove them since this is the correct behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was accidental. I only caught it because
isEmpty
was failing and I saw thatequals
was not correct. This then uncovered issue when reloadingFileRolesStore
.