Github user neykov commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/440#discussion_r90013209
--- Diff:
core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
---
@@ -163,13 +163,18 @@ public ConfigBag getLocalConfigBag() {
return putAllOwnConfigIntoSafely(ConfigBag.newInstance()).seal();
}
- public Object setConfig(ConfigKey<?> key, Object v) {
- Object val = coerceConfigVal(key, v);
+ public Object setConfig(final ConfigKey<?> key, Object v) {
+ // Use our own key for writing, (e.g. in-case it should (or should
not) be a structured key like MapConfigKey).
+ // This is same logic as for getConfig, except we only have to
look at our own container.
+ ConfigKey<?> ownKey = getKeyAtContainer(getContainer(), key);
+ if (ownKey==null) ownKey = key;
+
+ Object val = coerceConfigVal(ownKey, v);
--- End diff --
I guess it's useful for catching errors early. On the other hand the
uncertainty of what config key (and type) will be used to get values vs setting
them makes it harder to reason about the behaviour.
Say we are setting a double with an integer key - it will throw away the
fractional part. Then getting it back with a `Double` key.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---