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 2020/02/16 16:10:01 UTC

[camel] branch master updated: CAMEL-14572: camel-core - Optimize type converter for some basic convertions

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 90c877f  CAMEL-14572: camel-core - Optimize type converter for some basic convertions
90c877f is described below

commit 90c877f4c840697b8869958d24fdce2015518bc0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Feb 16 16:55:58 2020 +0100

    CAMEL-14572: camel-core - Optimize type converter for some basic convertions
---
 .../apache/camel/component/sql/stored/ProducerBatchInvalidTest.java   | 3 ++-
 .../org/apache/camel/impl/converter/BaseTypeConverterRegistry.java    | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ProducerBatchInvalidTest.java b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ProducerBatchInvalidTest.java
index 22bed0d..80fdcb2 100644
--- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ProducerBatchInvalidTest.java
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/ProducerBatchInvalidTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.sql.stored;
 import org.apache.camel.FailedToCreateRouteException;
 import org.apache.camel.PropertyBindingException;
 import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.TypeConversionException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.After;
@@ -71,7 +72,7 @@ public class ProducerBatchInvalidTest extends CamelTestSupport {
             ResolveEndpointFailedException refe = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
             PropertyBindingException pbe = assertIsInstanceOf(PropertyBindingException.class, refe.getCause());
             assertEquals("batch", pbe.getPropertyName());
-            assertIsInstanceOf(IllegalArgumentException.class, pbe.getCause());
+            assertIsInstanceOf(TypeConversionException.class, pbe.getCause());
             assertEquals("[true, true]", pbe.getValue().toString());
         }
     }
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java b/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
index aec5b68..62be24d 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
@@ -137,7 +137,7 @@ public abstract class BaseTypeConverterRegistry extends ServiceSupport implement
                 // primitive boolean which must return a value so throw exception if not possible
                 Object answer = ObjectConverter.toBoolean(value);
                 if (answer == null) {
-                    throw new IllegalArgumentException("Cannot convert type: " + value.getClass().getName() + " to boolean");
+                    throw new TypeConversionException(value, type, new IllegalArgumentException("Cannot convert type: " + value.getClass().getName() + " to boolean"));
                 }
                 return (T) answer;
             } else if (type == Boolean.class && (value instanceof String)) {
@@ -188,7 +188,7 @@ public abstract class BaseTypeConverterRegistry extends ServiceSupport implement
                 // primitive boolean which must return a value so throw exception if not possible
                 Object answer = ObjectConverter.toBoolean(value);
                 if (answer == null) {
-                    throw new IllegalArgumentException("Cannot convert type: " + value.getClass().getName() + " to boolean");
+                    throw new TypeConversionException(value, type, new IllegalArgumentException("Cannot convert type: " + value.getClass().getName() + " to boolean"));
                 }
                 return (T) answer;
             } else if (type == Boolean.class && (value instanceof String)) {