jamesfredley commented on code in PR #16772:
URL: https://github.com/apache/grails-core/pull/16772#discussion_r4385378726
##########
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:
`merge(['a.b.c': 'old'], true)` then `merge(['a[b].c': 'new'], true)`
exports `a.b.c=old`. The skip looks at the map name and not its leaves, so the
stale leaf stays.
Skip the map only when every descendant leaf is also exported at the new
value. Please cover that pair.
--
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]