brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #734: Support ConfigKey deprecated names
Date Mon, 26 Jun 2017 13:40:55 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/734#discussion_r123991510
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/config/ConfigBag.java ---
    @@ -507,6 +525,44 @@ protected Object getStringKey(String key, boolean markUsed) {
             return getStringKeyMaybe(key, markUsed).orNull();
         }
     
    +    private synchronized Maybe<Object> getRawKeyMaybe(ConfigKey<?> key, boolean
markUsed) {
    +        Maybe<Object> val = getRawStringKeyMaybe(key.getName(), markUsed);
    +        
    +        String firstDeprecatedName = null;
    +        Maybe<Object> firstDeprecatedVal = null;
    +        for (String deprecatedName : key.getDeprecatedNames()) {
    +            Maybe<Object> deprecatedVal = getRawStringKeyMaybe(deprecatedName,
markUsed);
    +            if (deprecatedVal.isPresent()) {
    +                if (val.isPresent()) {
    +                    if (!Objects.equal(val.get(), deprecatedVal.get())) {
    +                        log.warn("Conflicting value for key "+key+" from deprecated name
'"+deprecatedName+"'; "
    +                                + "using value from preferred name "+key.getName());
    +                    } else {
    +                        log.warn("Duplicate value for key "+key+" from deprecated name
'"+deprecatedName+"'; "
    +                                + "using same value from preferred name "+key.getName());
    +                    }
    +                } else if (firstDeprecatedVal.isPresent()) {
    --- End diff --
    
    is there not a potential NPE here, as `firstDeprecatedVal` is set to `null` initially,
and you'll arrive here without initializing it if `val` is not present?


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