matrei commented on code in PR #16772:
URL: https://github.com/apache/grails-core/pull/16772#discussion_r4402426127
##########
grails-bootstrap/src/main/groovy/org/grails/config/NavigableMap.groovy:
##########
@@ -374,15 +375,103 @@ class NavigableMap implements Map<String, Object>,
Cloneable {
Map<String, Object> toFlatConfig() {
Map<String, Object> flatConfig = [:]
flattenKeys(flatConfig, this, [], false)
+ removeDottedDuplicates(flatConfig)
flatConfig
}
Properties toProperties() {
Properties properties = new Properties()
flattenKeys((Map<Object, Object>) properties, this, [], true)
+ removeDottedDuplicates((Map<Object, Object>) properties)
Review Comment:
Non-blocking. Removing the duplicate config by config changes what
`CompositeConfig.toProperties()` gives when two configs spell one property
differently. The higher config's dotted copy used to shadow the lower config's
dotted key, and now the lower value shows through:
```groovy
def low = new PropertySourcesConfig(new MapPropertySource('low',
['app.routes.k': 'low']))
def high = new PropertySourcesConfig(new MapPropertySource('high',
['app.routes[k]': 'high']))
def composite = new CompositeConfig()
composite.addFirst(low)
composite.addFirst(high)
composite.getProperty('app.routes.k') // high
composite.toProperties()
// 7.0.x: app.routes.k=high, app.routes[k]=high; Binder binds app.routes as
[k: high]
// now: app.routes.k=low, app.routes[k]=high; Binder binds app.routes as
[k: low]
```
Nothing in the repository builds a `CompositeConfig` outside its spec, and a
GitHub code search found no other users, so I'm fine leaving it as is.
bd674957eb just made its `toProperties()` agree with `getProperty()`, though,
so a sentence in its javadoc saying that this case doesn't would help.
##########
grails-core/src/test/groovy/org/grails/config/PropertySourcesConfigSpec.groovy:
##########
@@ -184,6 +225,36 @@ class PropertySourcesConfigSpec extends Specification {
counter.readCount() == 1
}
+ void 'a dotted key inside a nested map is exported under its full path and
overwrites no other property'() {
Review Comment:
Nit: this feature and the next one moved below the placeholder features
unchanged. Leaving them where they were would keep them out of the diff and
keep their `git blame` on 20ca350112.
--
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]