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.
Filter stale role IDs in Infinispan client adapters #51616
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
base: main
Are you sure you want to change the base?
Filter stale role IDs in Infinispan client adapters #51616
Changes from all commits
73e2e890b6e844fe12735eb1957cd013fdeFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
Thanks for the suggestion. I checked the existing model/cache test infrastructure and confirmed that the existing tests cover the normal cache invalidation path.
For this specific regression, reproducing an unknown role ID in CachedClient deterministically requires bypassing the normal cache invalidation path. The available test infrastructure does not provide a supported API for injecting such a stale cached role ID, and Mockito is not an existing dependency of this module.
I therefore kept the fix limited to the null handling, matching the existing JPA implementation with Objects::nonNull, rather than introducing a new mocking dependency or relying on internal cache-state manipulation.
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.
Update: @ssilvert provided a concrete Mockito-based approach that instantiates ClientAdapter/ClientScopeAdapter directly with mocked RealmCacheSession/CachedClient/CachedClientScope collaborators — much simpler than I'd assumed, and it doesn't require touching internal cache state. Added junit-jupiter-api, junit-jupiter-engine, and mockito-core as test dependencies to model/infinispan (following the same coordinates already used in operator and ssf/transmitter), and added ClientAdapterTest/ClientScopeAdapterTest covering exactly this scenario. Both pass locally (Tests run: 2, Failures: 0, Errors: 0). Pushed in the latest commit.
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.
Same applies to CachedClientScope. The existing test infrastructure covers normal cache invalidation, but does not provide a supported way to inject an arbitrary stale role ID into the cached scope mappings.
Adding a mocking dependency or manipulating internal cache state solely for this race-condition scenario would add unnecessary test infrastructure to the module. The production change mirrors the existing JPA implementation by filtering unresolved RoleModel instances with Objects::nonNull.
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.
Update: @ssilvert provided a concrete Mockito-based approach that instantiates ClientAdapter/ClientScopeAdapter directly with mocked RealmCacheSession/CachedClient/CachedClientScope collaborators — much simpler than I'd assumed, and it doesn't require touching internal cache state. Added junit-jupiter-api, junit-jupiter-engine, and mockito-core as test dependencies to model/infinispan (following the same coordinates already used in operator and ssf/transmitter), and added ClientAdapterTest/ClientScopeAdapterTest covering exactly this scenario. Both pass locally (Tests run: 2, Failures: 0, Errors: 0). Pushed in the latest commit.