Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.0
-
None
Description
I tried to refactor
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; }
to
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; }
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.