jamesfredley commented on code in PR #16732:
URL: https://github.com/apache/grails-core/pull/16732#discussion_r4369042332
##########
grails-bootstrap/src/main/groovy/org/grails/config/NavigableMap.groovy:
##########
@@ -81,37 +129,48 @@ class NavigableMap implements Map<String, Object>,
Cloneable {
@Override
boolean containsKey(Object key) {
- delegateMap.containsKey(key)
+ delegateMap.containsKey(key) || (key instanceof String &&
!ABSENT.is(elementAt((String) key)))
}
@Override
boolean containsValue(Object value) {
delegateMap.containsValue(value)
}
- @CompileDynamic
@Override
Object get(Object key) {
Object result = delegateMap.get(key)
- if (result != null) {
- return result
+ if (result == null && key instanceof String) {
+ Object element = elementAt((String) key)
+ return ABSENT.is(element) ? null : element
}
- null
+ result
}
+ /** Writes the entry in both representations, as {@link #setProperty}
does, and returns the entry it replaces. */
@Override
Object put(String key, Object value) {
- delegateMap.put(key, value)
+ Object previous = delegateMap.get(key)
+ setProperty(key, value)
+ previous
}
+ /** Removes the entry from both representations, with the flat keys below
it, and returns it. */
@Override
Object remove(Object key) {
- delegateMap.remove(key)
+ Object previous = delegateMap.get(key)
+ if (key instanceof String) {
Review Comment:
`remove('app.names[0]')` on an empty map creates `app.names = [null]`, and
both keys then report present. The same call against `names: 'configured'`
replaces that value with `[null]`.
An absent indexed key must stay absent. Do not route removal through
assignment. Please cover both cases.
--
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]