8000 Check if provider implements OnUserCache for the user model by redmitry · Pull Request #54411 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Check if provider implements OnUserCache for the user model - #54411

Merged
ahus1 merged 3 commits into
keycloak:mainfrom
redmitry:main
Nov 10, 2026
Merged

ahus1 merged 3 commits into
keycloak:mainfrom
redmitry:main

Conversation

@redmitry
@redmitry redmitry commented Oct 28, 2026 •
Copy link
Copy Markdown
Contributor

Closes #54410

This is a safety check before casting that fix potential problems with custom UserProvider implementations.

Copilot AI balanced review requested due to automatic review settings October 28, 2026 12:01
@redmitry
redmitry requested review from a team as code owners October 28, 2026 12:01
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change guarding user-cache callbacks with an interface check.

No open issues 🎉

What changed in this PR

This PR makes user caching safer for custom UserProvider implementations by checking whether the delegate implements OnUserCache before invoking its callback.

Changes:

  • Replaces an unchecked cast with an instanceof pattern check, avoiding a ClassCastException for providers without OnUserCache.
  • Preserves the callback for providers that implement the interface.
File Description
model/​infinispan/​src/​main/​java/​org/​keycloak/​models/​cache/​infinispan/​UserCacheSession.java Guards the cache callback with an interface check.

Review effort: Balanced

Signed-off-by: Dmitry Repchevsky <redmitry@list.ru>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 07:12
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are blocking the custom UserProvider caching change.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:43
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues blocking approval.

No open issues 🎉

Review effort: Balanced

@ahus1 ahus1 changed the title #54410 bug fix Check if provider implements OnUserCache for the user model Nov 10, 2026
@ahus1 ahus1 self-assigned this Nov 10, 2026
@ahus1
ahus1 enabled auto-merge (squash) November 10, 2026 19:44
@ahus1
ahus1 merged commit d052236 into keycloak:main Nov 10, 2026
97 checks passed
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.

Casting UserProvider to the OnUserCache without checking

3 participants

0