Skip to content

Resolve the DevTools restart loader through the parent chain - #16324

Merged
jamesfredley merged 1 commit into
apache:fix/16287-devtools-gorm-entitiesfrom
jdaugherty:fix/16287-devtools-review
Sep 9, 2026
Merged

jamesfredley merged 1 commit into
apache:fix/16287-devtools-gorm-entitiesfrom
jdaugherty:fix/16287-devtools-review

Conversation

@jdaugherty

Copy link
Copy Markdown
Contributor

Follow-up to #16299 addressing review feedback.

Under a DevTools restart the thread context class loader is not always the RestartClassLoader. Tomcat swaps
in TomcatEmbeddedWebappClassLoader during context start, which delegates to the RestartClassLoader as its
parent. A check that matched only the loader's own type fell back to the base loader in that window, which
is how the Hibernate 5 SessionFactory on 8.0.0-M5 ended up with base-loader entity classes (#16287).
Current 8.0.x only avoids it because the datastore is now constructed before Tomcat starts.

  • Walk the loader parent chain in DevToolsClassLoaders; keep a fallback that already sees the restart loader.
  • Hibernate 5 mirrors Hibernate 7: connection source is the DataSource of record, the context supplies the
    class loader. Removes the duplicated bean-name derivation.
  • Drop the unreleased resolve() alias and the guide paragraph.
  • Specs cover the container-loader condition, which the previous specs did not exercise.

Under a DevTools restart the thread context class loader is not always the
RestartClassLoader itself. A servlet container swaps its web application
loader in during context start (Tomcat's TomcatEmbeddedWebappClassLoader),
and that loader delegates to the RestartClassLoader as its parent. A check
that matched only the loader's own type fell back to the base loader in
exactly that window, which is how a Hibernate 5 SessionFactory built while
Tomcat was starting ended up with base-loader entity classes (apache#16287). Walk
the parent chain instead, and keep a fallback that already sees the restart
loader.

Hibernate 5 now mirrors Hibernate 7: the connection source is always the
DataSource of record, and the application context, when present, supplies
the resource resolver and class loader. That removes the duplicated
bean-name derivation from the factory, and setApplicationContext no longer
replaces a DataSource that setDataSourceConnectionSource configured.

Drop the never-released resolve() alias and the guide paragraph describing
the internal wiring, and cover the container-loader case in the specs.
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (fix/16287-devtools-gorm-entities@a137709). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                          @@
##             fix/16287-devtools-gorm-entities     #16324   +/-   ##
=====================================================================
  Coverage                                    ?   54.7332%           
  Complexity                                  ?      20542           
=====================================================================
  Files                                       ?       2105           
  Lines                                       ?     101169           
  Branches                                    ?      17971           
=====================================================================
  Hits                                        ?      55373           
  Misses                                      ?      37773           
  Partials                                    ?       8023           
Files with missing lines Coverage Δ
...atastore/mapping/reflect/DevToolsClassLoaders.java 95.0000% <100.0000%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

CI / Functional Tests (Java 21, indy=true) > :grails-test-examples-scaffolding:integrationTest

Test Runs Flakiness
UserControllerSpec > User list ❌ 5% 🟠

🏷️ Commit: 29abfee
▶️ Tests: 52487 executed
⚪️ Checks: 76/76 completed

Test Failures

UserControllerSpec > User list (:grails-test-examples-scaffolding:integrationTest in CI / Functional Tests (Java 21, indy=true))
geb.waiting.WaitTimeoutException: condition did not pass in 30 seconds (failed with exception)
	at geb.waiting.Wait.waitFor(Wait.groovy:128)
	at geb.waiting.DefaultWaitingSupport.doWaitFor(DefaultWaitingSupport.groovy:55)
	at geb.waiting.DefaultWaitingSupport.waitFor(DefaultWaitingSupport.groovy:41)
	at geb.Page.waitFor(Page.groovy:120)
	at com.example.pages.LoginPage.login(LoginPage.groovy:39)
	at com.example.UserControllerSpec.User list(UserControllerSpec.groovy:48)
Caused by: Assertion failed: 

title != pageTitle && $('input', name: 'username').empty
|     |  |         |
|     |  |         false
|     |  'Please sign in'
|     false
'Please sign in'

	at com.example.pages.LoginPage.login_closure1(LoginPage.groovy:39)
	at com.example.pages.LoginPage.login_closure1(LoginPage.groovy)
	at geb.waiting.Wait.waitFor(Wait.groovy:117)
	... 5 more

Rerun Controls

Select tests to mute in this pull request:

  • UserControllerSpec > User list

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

@jamesfredley
jamesfredley merged commit 1917fef into apache:fix/16287-devtools-gorm-entities Sep 9, 2026
77 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants