8.0.x - make configurable: allow-bean-definition-overriding / allow-circular-references#15765
Open
codeconsole wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15765 +/- ##
==============================
==============================
🚀 New features to boost your workflow:
|
…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.
dbc161b to
0713d3c
Compare
✅ All tests passed ✅Test SummaryCI / Functional Tests (Java 21, indy=true) > :grails-test-examples-app1:integrationTest
🏷️ Commit: 9482237 Learn more about TestLens at testlens.app. |
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
We shouldn't force bad practices and start providing an exit strategy
WARNING: Bean overriding will be deprecated in a future release.
GrailsAppand the unit-test harnessGrailsApplicationBuilderhardcodedallowBeanDefinitionOverriding(true)andallowCircularReferences(true). Thissilently overrode any value an application set through the standard Spring Boot
properties
spring.main.allow-bean-definition-overridingandspring.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
trueto preserve Grails' historical behavior (a plain Spring Boot appdefaults both to
false). Applications can now opt into stricter startupsemantics:
Changes
GrailsApp.createApplicationContext()resolves both flagsfrom the configured environment (defaulting to
true).GrailsApplicationBuilder.createMainContext()resolves the same properties, read after configuration data is loaded and
before
refresh().the Application class configuration guide.
GrailsAppContextOverridingSpec(grails-core) andGrailsApplicationBuilderContextOverridingSpec(grails-databinding).Notes
true. Grails' own bootstrap relies on beandefinition overriding (the harness re-registers infrastructure beans such as
internalConfigurationAnnotationProcessor). The test suite documents thatdisabling overriding makes a Grails context fail fast with
BeanDefinitionOverrideException— which is exactly why the default differsfrom Spring Boot's.
GrailsApplicationBuilderlives ingrails-testing-support-core, but its fullbootstrap requires the servlet API, so its behavioral test lives in
grails-databinding(which has the servlet API on its test classpath andalready 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/codenarcTeston thechanged modules — no violations.