Neo4j: detect web applications without relying on the dispatcherServlet bean#15936
Merged
jdaugherty merged 3 commits intoJul 9, 2026
Merged
Conversation
Neo4jDataStoreSpringInitializer gated the open-session-in-view interceptor on the dispatcherServlet bean definition. That bean is registered by Spring Boot auto-configuration, so under the Grails 8 lifecycle (plugin beans drain before auto-configuration, apache#15934) the check always returned false and the interceptor silently stopped registering in web applications. The check still honours a dispatcherServlet definition when present but otherwise tests whether the registry is the web application context itself, a signal independent of auto-configuration ordering. The logic mirrors AbstractDatastoreInitializer.isWebApplicationRegistry() added to grails-datamapping-core in apache#15934 (where it is exercised by the hibernate5/hibernate7 OpenSessionInViewSpec integration tests); it is inlined here because this build resolves grails-datamapping-core from published artifacts that do not yet contain the shared method, and the override becomes removable once it does.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15936 +/- ##
==================================================
+ Coverage 49.3373% 49.3416% +0.0043%
+ Complexity 16775 16772 -3
==================================================
Files 1985 1985
Lines 93327 93327
Branches 16336 16336
==================================================
+ Hits 46045 46049 +4
+ Misses 40158 40150 -8
- Partials 7124 7128 +4 🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: 7690284 Learn more about TestLens at testlens.app. |
Contributor
|
B/c this source isn't part of our normal build, i've merged it to not loose track. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #15934, which retimes plugin bean registration to run before Spring Boot auto-configuration.
Neo4jDataStoreSpringInitializergates the open-session-in-view interceptor oncontainsBeanDefinition('dispatcherServlet')— a bean registered by Boot auto-configuration, so under the retimed lifecycle the check always returns false and the interceptor silently stops registering in web applications. This is the same defect #15934 found and fixed (with differential tests) in the hibernate5, hibernate7, and mongodb initializers.The check still honours a
dispatcherServletdefinition when present, but otherwise tests whether the registry is theWebApplicationContextitself — a signal independent of auto-configuration ordering. Safe to merge before or after #15934: under the current lifecycle both signals agree.Why inlined rather than shared
AbstractDatastoreInitializer.isWebApplicationRegistry()was added in grails-datamapping-core by #15934, but grails-data-neo4j is an independent Gradle build resolving grails-datamapping-core from published artifacts that don't yet contain the shared method. The method is mirrored here with identical logic (documented in its groovydoc); once this build depends on a grails-datamapping-core release that ships it, the local copy is a redundant override and can be deleted.Verification
The identical logic is exercised in #15934 by new
OpenSessionInViewSpecintegration tests in the hibernate5 and hibernate7app1example apps (differential-tested: interceptor present on 8.0.x, absent under the retimed lifecycle before the fix, present after). The grails-data-neo4j build could not be run locally — it pinsgrails-gradle-plugins:6.1.2, which is not resolvable from Maven Central and requires credentials forrepo.grails.org/restricted— so compile/test verification for this module relies on CI.Related: #15934 (parent change and shared fix), #15755 (superseded design discussion).