jamesfredley commented on code in PR #16772:
URL: https://github.com/apache/grails-core/pull/16772#discussion_r4384421574


##########
grails-bootstrap/src/main/groovy/org/grails/config/NavigableMap.groovy:
##########
@@ -418,6 +433,58 @@ class NavigableMap implements Map<String, Object>, 
Cloneable {
         }
     }
 
+    /**
+     * Whether a bracketed flat key exports the entry, so that the walk skips 
its dotted name. Below the map, the entry
+     * {@code /api/**} of {@code routes} is exported by {@code 
routes[/api/**]} when that key exports every name and value
+     * the entry would, and not when it holds another value, such as one a 
later dotted write left behind, or a map
+     * missing some of the entry's fields. At the map itself, a flat key such 
as {@code app.routes./api/**}, which a merge
+     * writes beside the nested entry, is skipped when a bracketed key such as 
{@code app.routes[/api/**]} splits it at
+     * one of its dots, since the walk of the nested maps exports the entry.
+     */
+    private static boolean isExportedInBrackets(NavigableMap owner, 
List<String> relativePath, String key, Object value) {
+        if (relativePath) {
+            String bracketedKey = 
"${relativePath.join('.')}[${key}]".toString()
+            return owner.containsKey(bracketedKey) && 
exportsAll(owner.get(bracketedKey), value)
+        }
+        for (int dot = key.indexOf('.'); dot > 0; dot = key.indexOf('.', dot + 
1)) {

Review Comment:
   `merge(['app.routes[k]': 'old'], true)` then `put('app.routes.k', 'new')` 
exports nothing. The base exported `app.routes.k=new`. This skip treats the old 
bracketed key as enough.
   
   Skip the dotted entry only when the export already has the current value. 
Please cover that `put`.



-- 
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]

Reply via email to