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:08:06 UTC

[camel] branch camel-3.0.x updated: 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 camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.0.x by this push:
     new d0af301  CAMEL-14273: Binding properties using source code generated configurer classes should deal with if the setter method threw exception.
d0af301 is described below

commit d0af3019f345c41ca9a3a2f743ed8a90613fe6e4
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);
                     }
                 }
             }