Skip to content

Neo4j: detect web applications without relying on the dispatcherServlet bean#15936

Merged
jdaugherty merged 3 commits into
apache:8.0.xfrom
codeconsole:fix/neo4j-web-application-detection
Jul 9, 2026
Merged

Neo4j: detect web applications without relying on the dispatcherServlet bean#15936
jdaugherty merged 3 commits into
apache:8.0.xfrom
codeconsole:fix/neo4j-web-application-detection

Conversation

@codeconsole

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #15934, which retimes plugin bean registration to run before Spring Boot auto-configuration. Neo4jDataStoreSpringInitializer gates the open-session-in-view interceptor on containsBeanDefinition('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 dispatcherServlet definition when present, but otherwise tests whether the registry is the WebApplicationContext itself — 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 OpenSessionInViewSpec integration tests in the hibernate5 and hibernate7 app1 example 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 pins grails-gradle-plugins:6.1.2, which is not resolvable from Maven Central and requires credentials for repo.grails.org/restricted — so compile/test verification for this module relies on CI.

Related: #15934 (parent change and shared fix), #15755 (superseded design discussion).

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

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.3416%. Comparing base (5e561da) to head (7690284).

Additional details and impacted files

Impacted file tree graph

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

see 2 files with indirect coverage changes

🚀 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 Jul 8, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 7690284
▶️ Tests: 53792 executed
⚪️ Checks: 59/59 completed


Learn more about TestLens at testlens.app.

@jdaugherty jdaugherty merged commit 9b01a07 into apache:8.0.x Jul 9, 2026
62 checks passed
@jdaugherty

Copy link
Copy Markdown
Contributor

B/c this source isn't part of our normal build, i've merged it to not loose track.

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