brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grkvlt <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Some further tidies in wake of la...
Date Sat, 11 Oct 2014 20:08:04 GMT
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/233#discussion_r18744054
  
    --- Diff: core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java ---
    @@ -343,22 +358,27 @@ public Location resolveForPeeking(LocationDefinition ld) {
             return resolve(ld, ConfigBag.newInstance().configure(LocalLocationManager.CREATE_UNMANAGED,
true).getAllConfig());
         }
     
    -    @Override
    +    @Override @Deprecated
         public Location resolve(LocationDefinition ld, Map<?,?> flags) {
             return resolveLocationDefinition(ld, flags, null);
         }
         
    +    /** @deprecated since 0.7.0 not used (and optionalName was ignored anyway) */
    +    @Deprecated
         public Location resolveLocationDefinition(LocationDefinition ld, Map locationFlags,
String optionalName) {
    +        return resolve(ld, null, locationFlags).get();
    +    }
    +    
    +    public Maybe<Location> resolve(LocationDefinition ld, Boolean manage, Map locationFlags)
{
             ConfigBag newLocationFlags = ConfigBag.newInstance(ld.getConfig())
                 .putAll(locationFlags)
                 .putIfAbsentAndNotNull(LocationInternal.NAMED_SPEC_NAME, ld.getName())
                 .putIfAbsentAndNotNull(LocationInternal.ORIGINAL_SPEC, ld.getName());
    -        try {
    -            return resolve(ld.getSpec(), newLocationFlags.getAllConfig());
    -        } catch (Exception e) {
    -            throw new IllegalStateException("Cannot instantiate location '"+
    -                (optionalName!=null ? optionalName : ld)+"' pointing at "+ld.getSpec()+":
"+e, e);
    -        }
    +        Maybe<Location> result = resolve(ld.getSpec(), manage, newLocationFlags.getAllConfigRaw());
    +        if (result.isPresent()) 
    +            return result;
    +        throw new IllegalStateException("Cannot instantiate location '"+ld+"' pointing
at "+ld.getSpec()+": "+
    +            Exceptions.collapseText( ((Absent<?>)result).getException() ));
    --- End diff --
    
    I wish there was a nicer way of getting the exception from a `Maybe.Absent` instance,
without the cast...


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