8000 updates for quarkus:dev mode by shawkins · Pull Request #47848 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

updates for quarkus:dev mode - #47848

Merged
vmuzikar merged 4 commits into
keycloak:mainfrom
shawkins:iss47077
May 2, 2026
Merged

vmuzikar merged 4 commits into
keycloak:mainfrom
shawkins:iss47077

Conversation

@shawkins
@shawkins shawkins commented Apr 8, 2026 •
Copy link
Copy Markdown
Contributor

closes: #47077

  • updated the quarkus:dev notes to more precisely define the limiations.
  • moved the restoration of the system properties to directly be a responsibility of KeycloakMain
  • removed test launch mode in favor of reusing non-server mode and added docs for some Environment methods.
  • ensures that we cleanup within the quarkus classloader, and the classloader used for running embedded instances

@shawkins shawkins changed the title Iss47077 updates for quarkus:dev mode, and removing test launch mode Apr 8, 2026
@shawkins
shawkins marked this pull request as ready for review April 8, 2026 17:31
@shawkins
shawkins requested review from a team as code owners April 8, 2026 17:31
@@ -769,40 +767,10 @@ private void configureUserDefinedPersistenceUnits(List<PersistenceXmlDescriptorB
*
* @param configSources
*/
@BuildStep( )
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 makes configureConfigSources unused and never even called by Quarkus?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Corrected.

@shawkins
shawkins force-pushed the iss47077 branch 2 times, most recently from ef2c034 to 76be4d4 Compare April 9, 2026 11:00
@shawkins
shawkins marked this pull request as draft April 9, 2026 11:00
@shawkins
shawkins marked this pull request as ready for review April 9, 2026 11:56
@shawkins
shawkins commented Apr 9, 2026
Copy link
Copy Markdown
Contributor Author

Now ready for a review

@@ -307,6 +311,11 @@ private void closeApplication() {
} catch (Exception cause) {
cause.printStackTrace();
}
try {
closed.await(); // wait for an orderly completion of all cleanup in the other thread
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.

As this is a test framework class, it almost doesn't matter, but in general, I can't make sense of this, can you elaborate what it solves? Because the comment says:

// wait for an orderly completion of all cleanup in the other thread

However, the stack should be: org.keycloak.Keycloak#closeApplication -> io.quarkus.bootstrap.app.RunningQuarkusApplication#close -> closeable from io.quarkus.runner.bootstrap.StartupActionImpl#runMainClass which runs these close tasks where you added CountDownLatch. And they are not strictly speaking the last to run (e.g. there is RuntimeApplicationShutdownBuildItem and few other actions). That may be irrelevant since we shouldn't rely on the impl. details anyway.

So this only makes sense if the io.quarkus.bootstrap.app.RunningQuarkusApplication#close has some asynchronous tasks, otherwise regardless of the thread switching it should only end the close invocation when all the tasks are done. If it doesn't work this way, I think it is dangerous considering all the class loader switching they are doing.

@shawkins shawkins Apr 9, 2026 •
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As this is a test framework class, it almost doesn't matter, but in general, I can't make sense of this, can you elaborate what it solves? Because the comment says:

It comes down to the cleanup I'm trying to do here: https://github.com/keycloak/keycloak/pull/47848/changes#diff-c1907932c84285e376fbc3a66277c655f30b91476db47834c3f5a81a7a45b319R89 - that is within the quarkus classloader after the application has been stopped. The quarkus classloader seems to be reused for dev mode reload - for example editing the command line.

That logic also restores the previous system properties - we unfortunately make extensive use of setting those.

So this only makes sense if the io.quarkus.bootstrap.app.RunningQuarkusApplication#close has some asynchronous tasks

application.close() completes asynchronously from the cleanup being done in https://github.com/keycloak/keycloak/pull/47848/changes#diff-c1907932c84285e376fbc3a66277c65 10000 5f30b91476db47834c3f5a81a7a45b319R89

There is further cleanup performed by the test logic when running in embedded mode - because it also modifies static state, including system properties. So I don't want these to trample each other.

An alternative would be to only do the https://github.com/keycloak/keycloak/pull/47848/changes#diff-c1907932c84285e376fbc3a66277c655f30b91476db47834c3f5a81a7a45b319R89 cleanup if running in dev mode, but I was thinking that having a more sequential startup and shutdown for embedded may be good in general.

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.

In that case it makes sense to add the startup task you are adding, I didn't realize there was the async exit. It doesn't eliminate every side-effect, but hopefully good enough for tests.

@shawkins shawkins changed the title updates for quarkus:dev mode, and removing test launch mode updates for quarkus:dev mode Apr 9, 2026
@vmuzikar vmuzikar 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.

LGTM (considering also @michalvavrik's deeper review). Thanks!

@vmuzikar
vmuzikar enabled auto-merge (squash) April 30, 2026 15:12
shawkins added 4 commits May 1, 2026 13:16
closes: keycloak#47077

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
# Conflicts:
#	quarkus/tests/junit5/src/main/java/org/keycloak/Keycloak.java
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
@vmuzikar
vmuzikar merged commit 98366ba into keycloak:main May 2, 2026
94 of 96 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
* fix: ensuring dev mode can fully reload the application

closes: keycloak#47077

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* also removing test launch mode

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* refining embedded mode cleanup

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
# Conflicts:
#	quarkus/tests/junit5/src/main/java/org/keycloak/Keycloak.java

* restoring test launch mode

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

---------

Signed-off-by: Steve 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.

Improvements for quarkus dev mode

3 participants

0