8000 Add unwrap() to providers and factories, so an extension can wrap them by ahus1 · Pull Request #55520 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Add unwrap() to providers and factories, so an extension can wrap them - #55520

Draft
ahus1 wants to merge 2 commits into
keycloak:mainfrom
ahus1:is-55519-provider-unwrap
Draft

ahus1 wants to merge 2 commits into
keycloak:mainfrom
ahus1:is-55519-provider-unwrap

Conversation

@ahus1
@ahus1 ahus1 commented Nov 25, 2026 •
Copy link
Copy Markdown
Member

Closes #55519

The pull request has two commits: the interface, and its use in place of the casts.

Decisions and assumptions:

  • unwrap returns null when nothing matches, so a cast that cannot fail today now fails with a NullPointerException when a wrapper does not delegate unwrap; the issue lists a helper with a clearer message as an alternative.
  • Only consumer casts are changed; the places where Keycloak reaches its own implementation are covered by Reach Keycloak's own providers instead of the default provider, so an extension can wrap them #55515.
  • The realm and user caches and the OpenTelemetry tracing provider use unwrap rather than a lookup by ID, as a second instance in the session would keep invalidations or scopes of its own.

ahus1 and others added 2 commits November 25, 2026 10:53
8000
A wrapper around a provider or a factory hides the implementation behind it
from code that casts. Unwrappable gives providers and factories a default
unwrap(Class) that returns the object itself if it has the type, which a
wrapper overrides to ask its delegate, so wrappers can stack.

Closes keycloak#55519

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Code that needs a capability of the configured provider, such as the
datastore's StoreManagers, the credential store of the user storage, the realm
and user caches, or the OpenTelemetry tracing provider, now calls unwrap()
instead of casting, so it keeps working when an extension wraps the provider.

Closes keycloak#55519

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unwrap() to providers and factories, so an extension can wrap them

1 participant

0