Skip to content

8.0.x - make configurable: allow-bean-definition-overriding / allow-circular-references#15765

Open
codeconsole wants to merge 2 commits into
apache:8.0.xfrom
codeconsole:feat/configurable-bean-overriding-circular-refs
Open

8.0.x - make configurable: allow-bean-definition-overriding / allow-circular-references#15765
codeconsole wants to merge 2 commits into
apache:8.0.xfrom
codeconsole:feat/configurable-bean-overriding-circular-refs

Conversation

@codeconsole

@codeconsole codeconsole commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

We shouldn't force bad practices and start providing an exit strategy

WARNING: Bean overriding will be deprecated in a future release.

GrailsApp and the unit-test harness GrailsApplicationBuilder hardcoded
allowBeanDefinitionOverriding(true) and allowCircularReferences(true). This
silently overrode any value an application set through the standard Spring Boot
properties spring.main.allow-bean-definition-overriding and
spring.main.allow-circular-references — so there was no way to turn either off.

Both now resolve those properties from the configured environment and default
to true
to preserve Grails' historical behavior (a plain Spring Boot app
defaults both to false). Applications can now opt into stricter startup
semantics:

spring:
  main:
    allow-bean-definition-overriding: false
    allow-circular-references: false

Changes

  • grails-coreGrailsApp.createApplicationContext() resolves both flags
    from the configured environment (defaulting to true).
  • grails-testing-support-coreGrailsApplicationBuilder.createMainContext()
    resolves the same properties, read after configuration data is loaded and
    before refresh().
  • docs — new "Bean Definition Overriding and Circular References" section in
    the Application class configuration guide.
  • testsGrailsAppContextOverridingSpec (grails-core) and
    GrailsApplicationBuilderContextOverridingSpec (grails-databinding).

Notes

  • The default is intentionally true. Grails' own bootstrap relies on bean
    definition overriding (the harness re-registers infrastructure beans such as
    internalConfigurationAnnotationProcessor). The test suite documents that
    disabling overriding makes a Grails context fail fast with
    BeanDefinitionOverrideException — which is exactly why the default differs
    from Spring Boot's.
  • GrailsApplicationBuilder lives in grails-testing-support-core, but its full
    bootstrap requires the servlet API, so its behavioral test lives in
    grails-databinding (which has the servlet API on its test classpath and
    already exercises the builder).

Verification

  • ./gradlew :grails-core:test :grails-databinding:test :grails-testing-support-core:test :grails-fields:test --rerun-tasks — green.
  • checkstyleMain/codenarcMain + checkstyleTest/codenarcTest on the
    changed modules — no violations.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.0000%. Comparing base (87c000a) to head (9482237).
⚠️ Report is 10 commits behind head on 8.0.x.

Additional details and impacted files

Impacted file tree graph

@@      Coverage Diff       @@
##   8.0.x   #15765   +/-   ##
==============================
==============================
🚀 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.

…rable

GrailsApp and the unit-test harness GrailsApplicationBuilder hardcoded
allowBeanDefinitionOverriding(true) and allowCircularReferences(true),
silently overriding any value set through the standard Spring Boot properties
spring.main.allow-bean-definition-overriding and
spring.main.allow-circular-references.

Both now resolve those properties from the configured environment, defaulting
to true to preserve Grails' historical behavior (a plain Spring Boot app
defaults both to false). Applications can opt into stricter startup semantics
via application.yml.

- grails-core: GrailsApp.createApplicationContext reads both flags from the
  configured environment.
- grails-testing-support-core: GrailsApplicationBuilder.createMainContext reads
  the same properties after configuration data is loaded and before refresh.
- docs: new section in the Application class configuration guide.
- tests: GrailsAppContextOverridingSpec (grails-core) and
  GrailsApplicationBuilderContextOverridingSpec (grails-databinding). The latter
  documents that disabling bean definition overriding fails a Grails unit
  context with BeanDefinitionOverrideException, which is why the default is true.
@codeconsole codeconsole force-pushed the feat/configurable-bean-overriding-circular-refs branch from dbc161b to 0713d3c Compare June 26, 2026 15:36
@testlens-app

testlens-app Bot commented Jun 26, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

⚠️ TestLens detected flakiness ⚠️

Test Summary

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

Test Runs
AsyncPromiseSpec > multi-stage process reports all stages ❌ ✅

🏷️ Commit: 9482237
▶️ Tests: 4498 executed
⚪️ Checks: 44/44 completed


Learn more about TestLens at testlens.app.

@codeconsole codeconsole changed the title Make bean definition overriding and circular references configurable 8.0.x - allow-bean-definition-overriding / allow-circular-references Jun 26, 2026
@codeconsole codeconsole changed the title 8.0.x - allow-bean-definition-overriding / allow-circular-references 8.0.x - make configurable: allow-bean-definition-overriding / allow-circular-references Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant