jamesfredley commented on code in PR #16552:
URL: https://github.com/apache/grails-core/pull/16552#discussion_r4214778842
##########
grails-core/src/main/groovy/grails/config/external/ExternalConfigRunListener.groovy:
##########
@@ -92,10 +94,11 @@ class ExternalConfigRunListener implements
SpringApplicationRunListener {
// Resolve final locations, taking into account user home prefix and file
wildcards
private List<Object> getLocations(ConfigurableEnvironment environment) {
- List<Object> locations =
environment.getProperty('grails.config.locations', List, []) as List<Object>
+ Binder binder = Binder.get(environment)
+ List<Object> locations = binder.bind('grails.config.locations',
Bindable.listOf(Object)).orElse([])
// See if grails.config.locations is defined in an environments block
like 'development' or 'test'
String environmentString =
"environments.${Environment.current.name}.grails.config.locations"
- locations = environment.getProperty(environmentString, List, locations)
+ locations = binder.bind(environmentString,
Bindable.listOf(Object)).orElse(locations)
Review Comment:
This bind uses the current environment name as a property segment. A
supported custom environment such as `-Dgrails.env=UAT` makes Binder throw
InvalidConfigurationPropertyNameException, because the name is not a canonical
lowercase property. Camel-case and underscore names fail the same way. The
listener runs this bind even when no external locations are configured, so
those applications fail during startup. Look the locations up in a way that
still accepts custom environment names.
##########
grails-core/src/test/groovy/org/grails/config/YamlPropertySourceLoaderSpec.groovy:
##########
@@ -157,6 +164,53 @@ class YamlPropertySourceLoaderSpec extends Specification {
config.getProperty('app.names', List) == ['p', 'q']
}
+ def "resolves placeholders in YAML scalar lists bound to configuration
properties with environment #variables"() {
+ given:
+ def source = load('''\
+ app:
+ allowedOrigins:
+ - https://static.example.com
+ - "${EXAMPLE_ALLOWED_ORIGIN:https://default.example.com}"
+ ports: [8080, "${EXAMPLE_PORT:9090}"]
+ flags: [true, "${EXAMPLE_FLAG:false}"]
+ groups: [["${EXAMPLE_GROUP:primary}"], [secondary]]
Review Comment:
This nested list does not survive flattening. The loader uses Spring keys
such as `app.groups[0][0]`, and NavigableMap.mergeMapEntry() keeps the text
after the first index at subscriptEnd + 2. Consecutive indexes drop the second
`[`, so the property source exposes `app.groups[0].0]` instead of
`app.groups[0][0]`, and Boot cannot bind List<List<String>>. Fix
consecutive-index parsing, and keep a test that fails when the nested list is
flattened incorrectly.
--
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]