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 2019/12/08 19:05:11 UTC
[camel] 02/03: CAMEL-14273: Binding properties using source code
generated configurer classes should deal with if the setter method threw
exception.
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
commit 6a8b8f83b32b46f6a017eecdb4608383d605492b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Dec 8 15:00:03 2019 +0100
CAMEL-14273: Binding properties using source code generated configurer classes should deal with if the setter method threw exception.
---
.../sql/stored/ProducerBatchInvalidTest.java | 5 ++++-
.../camel/support/PropertyBindingSupport.java | 24 +++++++++++-----------
2 files changed, 16 insertions(+), 13 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 bf7fc6c..37fe02c 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
@@ -17,6 +17,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;
@@ -69,7 +70,9 @@ public class ProducerBatchInvalidTest extends CamelTestSupport {
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException refe = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
- TypeConversionException pbe = assertIsInstanceOf(TypeConversionException.class, refe.getCause());
+ PropertyBindingException pbe = assertIsInstanceOf(PropertyBindingException.class, refe.getCause());
+ assertEquals("batch", pbe.getPropertyName());
+ TypeConversionException tce = assertIsInstanceOf(TypeConversionException.class, pbe.getCause());
assertEquals("[true, true]", pbe.getValue().toString());
}
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index d9c3b21..4d101c1 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -486,21 +486,21 @@ public final class PropertyBindingSupport {
valid = key.indexOf('.') == -1;
}
if (valid) {
- // GeneratedPropertyConfigurer works by invoking the methods directly but it does
- // not resolve property placeholders eventually defined in the value before invoking
- // the setter.
- if (value instanceof String) {
- value = camelContext.resolvePropertyPlaceholders((String) value);
- }
try {
+ // GeneratedPropertyConfigurer works by invoking the methods directly but it does
+ // not resolve property placeholders eventually defined in the value before invoking
+ // the setter.
+ if (value instanceof String) {
+ value = camelContext.resolvePropertyPlaceholders((String) value);
+ }
value = resolveValue(camelContext, target, key, value, ignoreCase, fluentBuilder, allowPrivateSetter);
+ boolean hit = gen.configure(camelContext, target, key, value, ignoreCase);
+ if (removeParameter && hit) {
+ iter.remove();
+ rc = true;
+ }
} catch (Exception e) {
- throw new PropertyBindingException(target, e);
- }
- boolean hit = gen.configure(camelContext, target, key, value, ignoreCase);
- if (removeParameter && hit) {
- iter.remove();
- rc = true;
+ throw new PropertyBindingException(target, key, value, e);
}
}
}