codeconsole commented on code in PR #16732:
URL: https://github.com/apache/grails-core/pull/16732#discussion_r4352458664


##########
grails-core/src/main/groovy/org/grails/config/NavigableMapConfig.java:
##########
@@ -217,67 +222,29 @@ public <T> T getProperty(String key, Class<T> targetType, 
T defaultValue, List<T
         return value;
     }
 
+    /**
+     * Reads the process environment again, so that a variable installed after 
this config was
+     * created, as a test can do reflectively, is seen by the lookups that 
follow.
+     */
+    protected void refreshSystemEnvironment() {
+        systemEnvironment = new SystemEnvironmentIndex(System.getenv());
+    }
+
     @Override
     public <T> T getProperty(String key, Class<T> targetType, T defaultValue) {
-        Object value = findInSystemEnvironment(key);
+        Object value = systemEnvironment.get(key);
         if (value == null) {
-            value = getValueWithDotNotatedKeySupport(configMap, key);
+            // merge and dot-notation assignment write the flat key as well as 
the nested entry, so the flat

Review Comment:
   Good catch, thanks. Fixed in 1fe52b49df: the second pass of a nested dotted 
key now carries the parent path, so `x: ['a.b': 'nested']` is flattened as 
`x.a.b` only and the root `a.b` keeps `root`. The bug is older than this PR, 
since any dotted key inside a nested block also wrote a key at the root 
(`logging.level: { org.springframework: DEBUG }` wrote a root 
`org.springframework`), but with walk-first `getProperty` happened to hide it 
while `config['a.b']` showed it. Pinned exactly as you asked in 
`PropertySourcesConfigSpec`, `a dotted key inside a nested map does not 
overwrite the root key it resembles`: `getProperty('a.b') == 'root'`, 
`navigate('a', 'b') == 'root'`, `getProperty('x.a.b') == 'nested'`, 
`navigate('x', 'a', 'b') == 'nested'`; and at the `NavigableMap` level in 
`NavigableMapSpec` for both representations. 5f1c39aedb adds a sentence to 
section 17 of the upgrade guide.
   



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