codeconsole commented on code in PR #16772:
URL: https://github.com/apache/grails-core/pull/16772#discussion_r4390269676
##########
grails-bootstrap/src/main/groovy/org/grails/config/NavigableMap.groovy:
##########
@@ -420,6 +435,64 @@ class NavigableMap implements Map<String, Object>,
Cloneable {
}
}
+ /**
+ * Whether a bracketed flat key exports the entry, so that the walk skips
its dotted name. The entry {@code /api/**} of
+ * {@code routes} is exported by {@code routes[/api/**]}, held by the
nearest enclosing nested map, when that key
+ * exports every name and value the entry would, and the walked map holds
no flat key under the entry's dotted name,
+ * {@code app.routes./api/**}, with another value. A flat key of the map
itself, such as {@code app.routes./api/**}, is
+ * exported by the bracketed key that splits it at one of its dots, {@code
app.routes[/api/**]}, when that key exports
+ * the same value. Where the bracketed key holds less, or a value a later
write replaced, or the dotted names hold
+ * values that differ, the dotted names are exported too, and the one
written last is the one exported under them.
+ */
+ private boolean isExportedInBrackets(NavigableMap owner, List<String>
path, List<String> relativePath, String key, Object value) {
+ if (relativePath) {
+ String bracketedKey =
"${relativePath.join('.')}[${key}]".toString()
+ if (!owner.containsKey(bracketedKey) ||
!exportsAll(owner.get(bracketedKey), value)) {
+ return false
+ }
+ String dottedName = "${path.join('.')}.${key}".toString()
Review Comment:
Fixed in 8fb4cad282. A map entry is now skipped only when no flat key holds
another value, either under its own dotted name or under the dotted name of any
value below it. This applies to nested entries and to flat keys of the walked
map. After your pair, `a.b.c` holds `'old'` while the map below `a.b` holds `c:
'new'`, so the map is exported under its dotted names too, and `a.b.c=new`
wins, as on 7.0.x. Where nothing below disagrees, the map is still exported
once, in brackets. The YAML, CORS and bracketed-map key sets are unchanged.
A row for your pair is in the "value written last" feature in
`ConfigMapSpec`, checking `a.b.c` through `toFlatConfig()` and
`toProperties()`. It fails at 1b27bef89f, the previous head. Both modules'
suites pass.
One level deeper was wrong in the merge rather than the export. After
`merge(['a.b.c.d': 'old'])` and `merge(['a[b].c.d': 'new'])`, the subscript
write put `c.d` into the `b` map as a single key. The nested map `c` kept `d:
'old'`, so `navigate('a', 'b', 'c', 'd')` read `'old'` too, as on 7.0.x. That
write belongs to #16771, which now fixes it (4ee8c8d42d): a nested map is
merged into, through the placeholder hook, and the flat key `a.b.c.d` takes the
value as well. With both PRs merged together, the export gives `a.b.c.d=new`.
--
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]