brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: add support for defining explicit...
Date Thu, 29 Jan 2015 10:47:33 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/483#discussion_r23759478
  
    --- Diff: core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java ---
    @@ -257,17 +282,35 @@ public void setInheritedConfig(Map<ConfigKey<?>, ? extends
Object> vals, ConfigB
                 ConfigKey<?> key = renamedConfigKeys.get(name);
                 if (key == null) key = entity.getEntityType().getConfigKey(name);
                 if (key != null) {
    -                if (inheritedConfig.containsKey(key)) {
    +                if (!isInherited(key)) {
    +                    // no-op
    +                } else if (inheritedConfig.containsKey(key)) {
                         LOG.warn("Entity "+entity+" inherited duplicate config for key "+key+",
via explicit config and string name "+name+"; using value of key");
                     } else {
                         inheritedConfig.put(key, value);
                     }
                 } else {
    +                // a config bag has discarded the keys, so we must assume default inheritance
for things given that way
    +                // unless we can infer a key; not a big deal, as we should have the key
in inheritedConfig for everything
    +                // which originated with a key ... but still, it would be nice to clean
up the use of config bag!
                     inheritedConfigBag.putStringKey(name, value);
                 }
             }
         }
         
    +    private Map<ConfigKey<?>, ?> filterUninheritable(Map<ConfigKey<?>,
?> valsO) {
    --- End diff --
    
    This impl looks correct but confusing. I'd have expected something simpler like:
    
        private Map<ConfigKey<?>, ?> filterUninheritable(Map<ConfigKey<?>,
?> vals) {
            Map<ConfigKey<?>, Object> result = Maps.newLinkedHashMap();
            for (Map.Entry<ConfigKey<?>, ?> entry : vals.entrySet()) {
                if (isInherited(entry.getKey())) {
                    result.put(entry.getKey(), entry.getValue());
                }
            }
            return result;
        }



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message