Updated Branches: refs/heads/master 3182ff08d -> 41f5c83e6
CAMEL-6781: IntrospectionSupport.setProperty ClassCastException if you have overloaded methods. Thanks to Franz Forsthofer for the patch. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0cd5463c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0cd5463c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0cd5463c Branch: refs/heads/master Commit: 0cd5463c44d4b8b9145b864907013af73c5dbab6 Parents: 3182ff0 Author: Claus Ibsen <[email protected]> Authored: Sun Sep 29 10:14:59 2013 +0200 Committer: Claus Ibsen <[email protected]> Committed: Sun Sep 29 10:14:59 2013 +0200 ---------------------------------------------------------------------- .../java/org/apache/camel/util/IntrospectionSupport.java | 8 ++++++-- .../impl/DefaultComponentReferencePropertiesTest.java | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/0cd5463c/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java index 3d6d6d0..e6864b7 100755 --- a/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java +++ b/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java @@ -496,9 +496,13 @@ public final class IntrospectionSupport { Object ref = value; // try and lookup the reference based on the method if (context != null && refName != null && ref == null) { - ref = CamelContextHelper.lookup(context, refName.replaceAll("#", ""), parameterType); + ref = CamelContextHelper.lookup(context, refName.replaceAll("#", "")); if (ref == null) { - continue; // try the next method if nothing was found + // try the next method if nothing was found + continue; + } else if (!parameterType.isAssignableFrom(ref.getClass())) { + // setter method has not the correct type + continue; } } http://git-wip-us.apache.org/repos/asf/camel/blob/0cd5463c/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java index bbec07c..1821991 100644 --- a/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java +++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentReferencePropertiesTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.impl; +import java.util.List; import java.util.Map; import org.apache.camel.CamelContext; @@ -58,6 +59,10 @@ public class DefaultComponentReferencePropertiesTest extends ContextTestSupport return null; } + public void setExpression(List<?> expressions) { + // do nothing + } + public void setExpression(Expression expression) { this.expression = expression; } @@ -104,14 +109,14 @@ public class DefaultComponentReferencePropertiesTest extends ContextTestSupport assertEquals("", remaining); assertEquals(1, parameters.size()); assertEquals("Christian", parameters.get("name")); - + return null; } - + }; component.createEndpoint("foo://?name=Christian"); } - + public void testOnlyStringSetter() throws Exception { MyComponent component = new MyComponent(context); MyEndpoint endpoint = (MyEndpoint) component.createEndpoint("foo://?name=Claus");
