jdaugherty opened a new pull request, #15949:
URL: https://github.com/apache/grails-core/pull/15949
## Description
Fixes #15818
Grails applications reject lenient configuration values (e.g. lowercase
enum names) that work in plain Spring Boot applications. For example, this
standard actuator configuration causes the application to fail on startup:
```yml
management:
endpoint:
heapdump:
access: unrestricted
Invalid value 'unrestricted' for configuration property
'management.endpoint.heapdump.access' ...
Failed to convert to type org.springframework.boot.actuate.endpoint.Access
Root cause: GrailsApp has overridden
SpringApplication.configureEnvironment() since Grails 3 without delegating to
super. Spring Boot's implementation installs the ApplicationConversionService
on the environment, which provides the lenient converters (lowercase/hyphenated
enum names, durations, etc.). Because Grails skipped that step, the environment
fell back to a plain DefaultConversionService, whose string-to-enum conversion
is case-sensitive. This only affects properties resolved directly through
environment.getProperty(name, type) — such as the actuator's
PropertiesEndpointAccessResolver — since @ConfigurationProperties binding
supplies its own conversion service.affects properties resolved directly
through environment.getProperty(name, type) — such as the actuator's
PropertiesEndpointAccessResolver — since @ConfigurationProperties binding
supplies its own conversion service.
Change: GrailsApp.configureEnvironment() now delegates to
super.configureEnvironment(environment, args) in place of the direct
configurePropertySources() call. This installs the conversion service while
preserving identical behavior otherwise (configureProfiles() is an empty method
in Spring Boot 3.x, and the Grails-specific profile handling is unchanged).
Tests:
- GrailsAppEnvironmentConversionSpec (grails-core) boots a minimal GrailsApp
and verifies lowercase (unrestricted) and hyphenated (read-only) enum values
resolve via environment.getProperty(). This spec fails without the fix.
- The grails-test-examples/external-configuration functional app now
declares the exact configuration from the issue
(management.endpoint.heapdump.access: unrestricted, threaddump.access:
read-only), which previously prevented startup, and the new
RelaxedPropertyResolutionSpec verifies both values resolve to the Access enum
through the Spring environment.
Contributor Checklist
Issue and Scope
- [x] This PR is linked to an existing issue that has been acknowledged or
approved by the project team.
- [x] This PR addresses the complete scope of the linked issue.
- [x] This PR contains a single, focused change.
- [x] This PR targets the correct branch for the type of change (bug fix
targeting 7.0.x).
Code Quality
- [x] I have added or updated tests that cover the changes introduced in
this PR.
- [ ] I have verified that all existing tests pass by running ./gradlew
build --rerun-tasks.
- [x] My code follows the project's code style guidelines.
- [x] This PR does not include mass reformatting, style-only changes, or
large-scale refactoring.
- [x] If generative AI tooling was used in preparing this contribution, a
quality model was used to ensure contributions are consistent with the
project's quality standards.
Licensing and Attribution
- [x] All contributed code is provided under the Apache License 2.0, and new
source files include the appropriate Apache license header.
- [x] I have the necessary rights to submit this contribution and confirm it
is my own original work.
- [x] If generative AI tooling was used in preparing this contribution, I
have followed the ASF's policy on generative tooling and have properly
attributed its use.
Documentation
- [x] If this PR introduces user-facing changes, I have included or updated
the relevant documentation. (No doc change needed — this restores documented
Spring Boot behavior; no new or changed public API.)
- [x] If this PR adds a new feature, I have updated the What's New section.
(N/A — bug fix.)
- [x] If this PR introduces breaking changes... (N/A — no user action
required.)
- [x] The PR description clearly explains what was changed and why.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]