8000 fix: combining / removing static and initialization logic by shawkins · Pull Request #46918 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
1 < 8000 link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-react-brand-css.44c4dd9dc16bc7c7.module.css" />

fix: combining / removing static and initialization logic - #46918

Merged
shawkins merged 2 commits into
keycloak:mainfrom
shawkins:static
Apr 7, 2026
Merged

shawkins merged 2 commits into
keycloak:mainfrom
shawkins:static

Conversation

@shawkins
@shawkins shawkins commented Mar 5, 2026
Copy link
Copy Markdown
Contributor
8000

closes: #46917

@shawkins
shawkins commented Mar 5, 2026
Copy link
Copy Markdown
Contributor Author

@pedroigor I recall we spoke some time ago about rationalizing the keycloak initialization logic more. This pr, #46378 and some follow-up work should hopefully clean things up a bit.

It may even be possible to eventually have the provider logic in quarkus be based upon CDI - I think that would open up another level of quarkus tests for us without the need to bring up the full server.

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.model.session.UserSessionPersisterProviderTest#testExpirationDistribution

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

org.keycloak.testsuite.model.session.UserSessionProviderModelTest#testStreamsMarshalling

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

org.keycloak.testsuite.model.session.OfflineSessionPersistenceTest#testPersistenceMultipleNodesClientSessionAtSameNode

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (TIMED_WAITING): locked on java.util.concurrent.FutureTask@531b06 waiting for 80741 ms blocked for 0 ms
	at java.base@25.0.2/jdk.internal.misc.Unsafe.park(Native Method)
	at java.base@25.0.2/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:271)
	at java.base@25.0.2/java.util.concurrent.FutureTask.awaitDone(FutureTask.java:508)
...

Report flaky test

org.keycloak.testsuite.model.session.UserSessionPersisterProviderTest#testUserRemoved

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

pruivo
pruivo previously approved these changes Mar 19, 2026
@pruivo pruivo left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ahus1
ahus1 commented Mar 19, 2026
Copy link
Copy Markdown
Member

@shawkins - thank you for letting the other PR go in first. Your PR now needs a conflict resolution :(

closes: keycloak#46917

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
@shawkins
Copy link
Copy Markdown
Contributor Author

@shawkins - thank you for letting the other PR go in first. Your PR now needs a conflict resolution :(

No problem, it should be good to look at again.

@pruivo based upon my previous changes it seemed simpler to just remove the parameterization of the session factory - let me know if you need that for something else.

There will be a few more static refinements coming after #47077

@pruivo
pruivo commented Mar 19, 2026
Copy link
Copy Markdown
Member

@shawkins - thank you for letting the other PR go in first. Your PR now needs a conflict resolution :(

No problem, it should be good to look at again.

@pruivo based upon my previous changes it seemed simpler to just remove the parameterization of the session factory - let me know if you need that for something else.

There will be a few more static refinements coming after #47077

Sure. I only added the parameterization because the KeycloakSessionFactory interface didn't have an init() method to invoke.
I'll review this PR tomorrow. Thank you.

@mabartos mabartos left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@shawkins Nice work!

pruivo
pruivo previously approved these changes Mar 20, 2026
@pruivo pruivo left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks good to me. Thank you.

mabartos
mabartos previously approved these changes Mar 20, 2026
@mabartos mabartos left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@shawkins @pruivo Thanks for the review and comments. LGTM

@vmuzikar
Copy link
Copy Markdown
Contributor

Given the close 26.6 release, I'd like to wait with merging this one. It's a bigger change and "just" an enhancement, still bringing some potential regressions. @shawkins Are you ok with putting this on hold for a bit?

@shawkins
Copy link
Copy Markdown
Contributor Author

Given the close 26.6 release, I'd like to wait with merging this one. It's a bigger change and "just" an enhancement, still bringing some potential regressions. @shawkins Are you ok with putting this on hold for a bit?

I'm not sure it needs to be formally put on hold just yet - unless you think it has sufficient reviews.

In which case, can you identify specific concerns so the changes could be split into what would be acceptable?

Ideally I'd like to address #47077 as well, and at the very least I'd like all the wiring of our session factory within quarkus to be correct.

@vmuzikar
Copy link
Copy Markdown
Contributor

In which case, can you identify specific concerns so the changes could be split into what would be acceptable?

My concern are potential regressions. It's not an isolated change (like e.g. the Client v2 changes are) and we're in a "polishing" phase before the release, avoiding potentially risky changes.

@shawkins
Copy link
Copy Markdown
Contributor Author

My concern are potential regressions. It's not an isolated change (like e.g. the Client v2 changes are) and we're in a "polishing" phase before the release, avoiding potentially risky changes.

I understand, that's why I was asking for a qualification of what is risky.

However if you are saying that we don't want any changes along these lines before 26.6, that's fine too. I was waiting for a review from @pedroigor regardless.

@mabartos mabartos added the status/hold PR should not be merged. On hold for later. label Mar 30, 2026
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
@shawkins
shawkins dismissed stale reviews from mabartos and pruivo via fdce5c7 April 7, 2026 14:53
@pedroigor
pedroigor commented Apr 7, 2026 •
Copy link
Copy Markdown
Contributor

It may even be possible to eventually have the provider logic in quarkus be based upon CDI - I think that would open up another level of quarkus tests for us without the need to bring up the full server.

Do you mean introducing a (CDI) bridge between the session factory and making it possible to inject kc-session- (and factory) into tests? Similar to model tests?

@shawkins
shawkins commented Apr 7, 2026
Copy link
Copy Markdown
Contributor Author

Do you mean introducing a (CDI) bridge between the session factory and making it possible to inject kc-session-scoped beans into tests? Similar to model tests?

Yes

To clarify, near-term goal here is mostly cleanup.

The next goal is to make sure that we can use a full application reload in quarkus dev mode such that we're appropriately cleaning up / reinitializing our state (#47077)

Tackling a more targeted testing strategy with QuarkusTests would come much later.

@pedroigor pedroigor 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.

Much cleaner .... Having the KSF as a bean and moving init logic to their own place improves a lot, plus redundant code when deploying providers at runtime ....

If tests pass, LGTM from me.

@shawkins
shawkins enabled auto-merge (squash) April 7, 2026 16:02
@shawkins
shawkins requested a review from pedroigor April 7, 2026 16:10
@shawkins
shawkins merged commit bb10a2c into keycloak:main Apr 7, 2026
92 of 94 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
…6918)

closes: keycloak#46917

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.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.

Remove application/sessionfactory logic that is no longer needed

6 participants

0