Author: davsclaus
Date: Mon Apr 16 07:53:08 2012
New Revision: 1326525

URL: http://svn.apache.org/viewvc?rev=1326525&view=rev
Log:
CAMEL-5172: Fixed and improved TypeConverter to fail faster by throwing 
TypeConversionException to the caller. Use the new tryConvertTo API for the old 
behavior. This would also be more in line what people would expect that 
exceptions to be propated back as is to the caller.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1326525&r1=1326524&r2=1326525&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java 
(original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java 
Mon Apr 16 07:53:08 2012
@@ -152,7 +152,7 @@ public final class ObjectHelper {
 
         // prefer to coerce to the right hand side at first
         if (rightValue instanceof Comparable) {
-            Object value = converter.convertTo(rightValue.getClass(), 
leftValue);
+            Object value = converter.tryConvertTo(rightValue.getClass(), 
leftValue);
             if (value != null) {
                 return ((Comparable) rightValue).compareTo(value) * -1;
             }
@@ -160,7 +160,7 @@ public final class ObjectHelper {
 
         // then fallback to the left hand side
         if (leftValue instanceof Comparable) {
-            Object value = converter.convertTo(leftValue.getClass(), 
rightValue);
+            Object value = converter.tryConvertTo(leftValue.getClass(), 
rightValue);
             if (value != null) {
                 return ((Comparable) leftValue).compareTo(value);
             }


Reply via email to