You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/09/29 10:28:53 UTC

[2/4] git commit: CAMEL-6781: IntrospectionSupport.setProperty ClassCastException if you have overloaded methods. Thanks to Franz Forsthofer for the patch.

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/5dbe9ce3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5dbe9ce3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5dbe9ce3

Branch: refs/heads/camel-2.11.x
Commit: 5dbe9ce3748de800364dc2d8f6fe738b14c2b888
Parents: f79a58a
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Sep 29 10:14:59 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Sep 29 10:28:39 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/5dbe9ce3/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 22bb389..a7ae39f 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
@@ -477,9 +477,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/5dbe9ce3/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");