codeconsole commented on code in PR #16732:
URL: https://github.com/apache/grails-core/pull/16732#discussion_r4371590811
##########
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
+ // key answers nearly every lookup without a walk; where the two
disagree the flat key wins.
+ value = configMap.get(key);
Review Comment:
Fixed in 5bc5a051b0. `replaceAll` is built on `entrySet()`, and the views
`entrySet()`, `keySet()` and `values()` were the delegate map's own, so a write
through them, `replaceAll`, `removeIf`, an entry's `setValue`, a removal
through an iterator or through the key or value collection, and `clear()` on a
nested map, reached one representation only. The views now write through: an
entry's `setValue` writes both representations as `put` does, a removal through
any of them removes both as `remove` does, and `clear()` on a nested map
removes its flat keys with its entries. Each view iterates the entries as they
were when its iterator was asked for, so a write through it never trips over
its own change. The methods of `Map` built on `get`, `put` and `remove`,
`compute`, `merge`, `putIfAbsent` and `replace`, already wrote both.
Pinned in `NavigableMapSpec` with your `replaceAll` and with each of the
other writes through the views, `setValue`, `replace`, `compute`,
`computeIfPresent`, `merge`, an iterator's `remove`, `removeIf` on the entries
and on the keys, `remove` on the keys and on the values, and `retainAll`, each
read back through the flat key, `containsKey` and `navigate`; a `replaceAll` on
the root, which writes the nested entry of a flat key; and `clear()` on a
nested map and on the root. `PropertySourcesConfigSpec` reads your sequence
through a config, and a `removeIf` after it.
--
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]