You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by tbouron <gi...@git.apache.org> on 2017/02/09 15:21:09 UTC

[GitHub] brooklyn-server pull request #521: fix unexpected AddChildrenEffector behavi...

Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/521#discussion_r100310679
  
    --- Diff: camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/DslDeferredFunctionCall.java ---
    @@ -99,48 +99,81 @@ public Object call() throws Exception {
         }
     
         protected static Maybe<Object> invokeOn(Object obj, String fnName, List<?> args) {
    -        Object instance = obj;
    -        List<?> instanceArgs = args;
    -        Maybe<Method> method = Reflections.getMethodFromArgs(instance, fnName, instanceArgs);
    -
    -        if (method.isAbsent()) {
    +        return new Invoker(obj, fnName, args).invoke();
    +    }
    +    
    +    protected static class Invoker {
    +        final Object obj;
    +        final String fnName;
    +        final List<?> args;
    +        
    +        Maybe<Method> method;
    +        Object instance;
    +        List<?> instanceArgs;
    +        
    +        protected Invoker(Object obj, String fnName, List<?> args) {
    +            this.fnName = fnName;
    +            this.obj = obj;
    +            this.args = args;
    +        }
    +        
    +        protected Maybe<Object> invoke() {
    +            findMethod();
    +            
    +            if (method.isPresent()) {
    +                Method m = method.get();
    +    
    +                checkCallAllowed(m);
    +    
    +                try {
    +                    // Value is most likely another BrooklynDslDeferredSupplier - let the caller handle it,
    +                    return Maybe.of(Reflections.invokeMethodFromArgs(instance, m, instanceArgs));
    +                } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
    +                    // If the method is there but not executable for whatever reason fail with a fatal error, don't return an absent.
    +                    throw Exceptions.propagate(new InvocationTargetException(e, "Error invoking '"+fnName+instanceArgs+"' on '"+instance+"'"));
    --- End diff --
    
    Miss `(` and `)` around `instanceArgs`
    
    Unless you can you your `DslToStringHelpers.fn()` ? 


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