brooklyn-dev mailing list archives

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

    https://github.com/apache/brooklyn-server/pull/734#discussion_r124580007
  
    --- 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 --
    
    Good spot! I've added a failing test, and then fixed the NPE.


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