essobedo commented on code in PR #11656:
URL: https://github.com/apache/camel/pull/11656#discussion_r1347567962


##########
core/camel-base/src/main/java/org/apache/camel/impl/converter/CoreTypeConverterRegistry.java:
##########
@@ -107,7 +107,7 @@ private <T> T fastConvertTo(Class<T> type, Exchange 
exchange, Object value) {
             return null;
         }
 
-        if (type.isInstance(value)) {
+        if (type.equals(value.getClass())) {

Review Comment:
   This sounds really risky since `value` could be an instance of a subclass 
like in the next example:
   
   Given:
   ```
   public interface Animal {
   }
   
   public static class Dog implements Animal {
   }
   ```
   When:
   ```
   Dog pluto = new Dog();
   System.out.println("Is pluto an animal? Using isInstance " + 
(Animal.class.isInstance(pluto) ? "Yes" : "No"));
   System.out.println("Is pluto an animal? Using Equals " + 
(Animal.class.equals(pluto.getClass()) ? "Yes" : "No"));
   ```
   Then
   ```
   Is pluto an animal? Using isInstance Yes
   Is pluto an animal? Using Equals No
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to