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/06/26 20:45:55 UTC

[camel] branch master updated (58330e6 -> 47b9d46)

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

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


    from 58330e6  CAMEL-13209: Fix Karaf tests close #2924
     new 8394722  CAMEL-13683: Fixed issue in PropertyBindingSupport
     new 47b9d46  CAMEL-13688: Camel main - Setting boolean option should have strict conversition

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/file/FileKeepLastModifiedTest.java  |  4 ++--
 .../main/java/org/apache/camel/main/MainSupport.java    | 17 +++++++++++++----
 .../org/apache/camel/support/IntrospectionSupport.java  |  8 ++++++++
 .../apache/camel/support/PropertyBindingSupport.java    | 17 +++++++++--------
 4 files changed, 32 insertions(+), 14 deletions(-)


[camel] 02/02: CAMEL-13688: Camel main - Setting boolean option should have strict conversition

Posted by da...@apache.org.
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 47b9d4658d27ee9207e33a207824aba351f50e5e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 26 22:44:21 2019 +0200

    CAMEL-13688: Camel main - Setting boolean option should have strict conversition
---
 .../camel/component/file/FileKeepLastModifiedTest.java  |  4 ++--
 .../main/java/org/apache/camel/main/MainSupport.java    | 17 +++++++++++++----
 .../org/apache/camel/support/IntrospectionSupport.java  |  8 ++++++++
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
index a5ffd83..df51d01 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
@@ -38,7 +38,7 @@ public class FileKeepLastModifiedTest extends ContextTestSupport {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/data/keep?noop=true?initialDelay=0&delay=10")
+                from("file://target/data/keep?noop=true&initialDelay=0&delay=10")
                     .delay(10)
                     .to("file://target/data/keep/out?keepLastModified=true", "mock:result");
             }
@@ -64,7 +64,7 @@ public class FileKeepLastModifiedTest extends ContextTestSupport {
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/data/keep?noop=true?initialDelay=0&delay=10")
+                from("file://target/data/keep?noop=true&initialDelay=0&delay=10")
                     .delay(10)
                     .to("file://target/data/keep/out?keepLastModified=false", "mock:result");
             }
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index b0879e5..1bc0c97 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -1195,12 +1195,21 @@ public abstract class MainSupport extends ServiceSupport {
             LOG.debug("Setting property {} on {} with value {}", name, target, stringValue);
             if (failIfNotSet) {
                 PropertyBindingSupport.bindMandatoryProperty(context, target, name, stringValue, ignoreCase);
+                it.remove();
                 rc = true;
             } else {
-                boolean hit = PropertyBindingSupport.bindProperty(context, target, name, stringValue, ignoreCase);
-                if (hit) {
-                    it.remove();
-                    rc = true;
+                try {
+                    boolean hit = PropertyBindingSupport.bindProperty(context, target, name, stringValue, ignoreCase);
+                    if (hit) {
+                        it.remove();
+                        rc = true;
+                    }
+                } catch (Exception e) {
+                    if (failIfNotSet) {
+                        throw e;
+                    } else {
+                        LOG.debug(e.getMessage() + ". This exception is ignored.", e);
+                    }
                 }
             }
         }
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
index 21c5d9a..9883396 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
@@ -711,6 +711,14 @@ public final class IntrospectionSupport {
                         return true;
                     } else {
                         // We need to convert it
+                        // special for boolean values with string values as we only want to accept "true" or "false"
+                        if (parameterType == Boolean.class || parameterType == boolean.class && ref instanceof String) {
+                            String val = (String) ref;
+                            if (!val.equalsIgnoreCase("true") && !val.equalsIgnoreCase("false")) {
+                                throw new IllegalArgumentException("Cannot convert the String value: " + ref + " to type: " + parameterType
+                                        + " as the value is not true or false");
+                            }
+                        }
                         Object convertedValue = typeConverter != null ? typeConverter.mandatoryConvertTo(parameterType, ref) : ref;
                         // we may want to set options on classes that has package view visibility, so override the accessible
                         setter.setAccessible(true);


[camel] 01/02: CAMEL-13683: Fixed issue in PropertyBindingSupport

Posted by da...@apache.org.
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 8394722164b1fc363ad2826e46e27c6175ef0876
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jun 26 18:23:37 2019 +0200

    CAMEL-13683: Fixed issue in PropertyBindingSupport
---
 .../apache/camel/support/PropertyBindingSupport.java    | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

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 0d32d91..f41d860 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
@@ -464,15 +464,16 @@ public final class PropertyBindingSupport {
      * @param ignoreCase    whether to ignore case for property keys
      */
     public static void bindMandatoryProperty(CamelContext camelContext, Object target, String name, Object value, boolean ignoreCase) {
-        try {
-            if (target != null && name != null) {
-                boolean bound = setProperty(camelContext, target, name, value, true, ignoreCase, true, true, true, true, true, true);
-                if (!bound) {
-                    throw new PropertyBindingException(target, name);
-                }
+        boolean bound;
+        if (target != null && name != null) {
+            try {
+                bound = setProperty(camelContext, target, name, value, true, ignoreCase, true, true, true, true, true, true);
+            } catch (Exception e) {
+                throw new PropertyBindingException(target, name, e);
+            }
+            if (!bound) {
+                throw new PropertyBindingException(target, name);
             }
-        } catch (Exception e) {
-            throw new PropertyBindingException(target, name, e);
         }
     }