CAMEL-8782: Configuring endpoints using reference lookup may fail with matching 
primitive types with their Object counterpart types


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6aaec822
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6aaec822
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6aaec822

Branch: refs/heads/master
Commit: 6aaec82213c0a9eefe0675d57ad6f8d8dff0aa4d
Parents: 2bd2331
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue May 19 21:49:34 2015 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue May 19 21:54:31 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/util/IntrospectionSupport.java     | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6aaec822/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 d04c310..13ceba9 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
@@ -43,6 +43,8 @@ import org.apache.camel.TypeConverter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.util.ObjectHelper.isAssignableFrom;
+
 /**
  * Helper for introspections of beans.
  * <p/>
@@ -502,16 +504,20 @@ public final class IntrospectionSupport {
                 if (ref == null) {
                     // try the next method if nothing was found
                     continue;
-                } else if (!parameterType.isAssignableFrom(ref.getClass())) {
+                } else {
                     // setter method has not the correct type
-                    continue;
+                    // (must use ObjectHelper.isAssignableFrom which takes 
primitive types into account)
+                    boolean assignable = isAssignableFrom(parameterType, 
ref.getClass());
+                    if (!assignable) {
+                        continue;
+                    }
                 }
             }
 
             try {
                 try {
                     // If the type is null or it matches the needed type, just 
use the value directly
-                    if (value == null || 
parameterType.isAssignableFrom(ref.getClass())) {
+                    if (value == null || isAssignableFrom(parameterType, 
ref.getClass())) {
                         // we may want to set options on classes that has 
package view visibility, so override the accessible
                         setter.setAccessible(true);
                         setter.invoke(target, ref);

Reply via email to