You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2011/01/15 17:27:45 UTC

[jira] Commented: (CAMEL-3545) MethodCallExpression doesn't validate whether the method exists for all cases

    [ https://issues.apache.org/jira/browse/CAMEL-3545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12982123#action_12982123 ] 

Claus Ibsen commented on CAMEL-3545:
------------------------------------

See CAMEL-2920

I improved the validation check to test in all 3 cases now.

trunk: 1059363.

> MethodCallExpression doesn't validate whether the method exists for all cases
> -----------------------------------------------------------------------------
>
>                 Key: CAMEL-3545
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3545
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.5.0
>            Reporter: Christian Müller
>            Assignee: Claus Ibsen
>             Fix For: 2.6.0
>
>
> I tried to refactor
> {code:title=org.apache.camel.model.language.MethodCallExpression.java}
>     public Expression createExpression(CamelContext camelContext) {
>         Expression answer;
>         if (beanType != null) {            
>             instance = ObjectHelper.newInstance(beanType);
>             return new BeanExpression(instance, getMethod(), parameterType); // <--
>         } else if (instance != null) {
>             return new BeanExpression(instance, getMethod(), parameterType); // <--
>         } else {
>             String ref = beanName();
>             // if its a ref then check that the ref exists
>             BeanHolder holder = new RegistryBean(camelContext, ref);
>             // get the bean which will check that it exists
>             instance = holder.getBean();
>             answer = new BeanExpression(ref, getMethod(), parameterType);
>         }
>         // validate method
>         validateHasMethod(camelContext, instance, getMethod(), parameterType);
>         return answer;
>     }
> {code}
> to
> {code:title=org.apache.camel.model.language.MethodCallExpression.java}
>     public Expression createExpression(CamelContext camelContext) {
>         Expression answer;
>         if (beanType != null) {            
>             instance = ObjectHelper.newInstance(beanType);
>             answer = new BeanExpression(instance, getMethod(), parameterType); // <--
>         } else if (instance != null) {
>             answer = new BeanExpression(instance, getMethod(), parameterType); // <--
>         } else {
>             String ref = beanName();
>             // if its a ref then check that the ref exists
>             BeanHolder holder = new RegistryBean(camelContext, ref);
>             // get the bean which will check that it exists
>             instance = holder.getBean();
>             answer = new BeanExpression(ref, getMethod(), parameterType);
>         }
>         // validate method
>         validateHasMethod(camelContext, instance, getMethod(), parameterType);
>         return answer;
>     }
> {code}
> so that the created BeanExpression is also validate if you provide the bean type or an instance. With this change, some tests in org.apache.camel.language.SimpleTest fails.
> I'm not sure whether the tests are faulty or if it's a bug.
> Also not sure whether this should fixed in 2.6. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.