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

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


The following commit(s) were added to refs/heads/camel-4.14.x by this push:
     new 778f4a318c09 CAMEL-22978: Fix quoted boolean parameter matching in 
PropertyBindingSupport (#21422)
778f4a318c09 is described below

commit 778f4a318c09c0117bbaad82a44990cb5bae071b
Author: deepaktaker <[email protected]>
AuthorDate: Thu Feb 12 17:27:03 2026 +0530

    CAMEL-22978: Fix quoted boolean parameter matching in 
PropertyBindingSupport (#21422)
    
    Co-authored-by: Deepak MP <[email protected]>
---
 ...opertyBindingSupportClassFactoryMethodTest.java | 107 +++++++++++++++++++++
 .../PropertyBindingSupportConstructorTest.java     | 103 ++++++++++++++++++++
 .../camel/support/PropertyBindingSupport.java      |  12 ++-
 3 files changed, 219 insertions(+), 3 deletions(-)

diff --git 
a/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportClassFactoryMethodTest.java
 
b/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportClassFactoryMethodTest.java
index 464621a23bb4..7d32fe2ea010 100644
--- 
a/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportClassFactoryMethodTest.java
+++ 
b/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportClassFactoryMethodTest.java
@@ -24,6 +24,8 @@ import org.apache.camel.support.PropertyBindingSupport;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Unit test for PropertyBindingSupport
@@ -84,6 +86,72 @@ public class PropertyBindingSupportClassFactoryMethodTest {
         context.stop();
     }
 
+    @Test
+    public void testFactoryQuotedBoolean() {
+        CamelContext context = new DefaultCamelContext();
+
+        context.start();
+
+        MyAppWithConfig target = new MyAppWithConfig();
+
+        PropertyBindingSupport.build()
+                .withCamelContext(context)
+                .withTarget(target)
+                .withProperty("name", "Donald")
+                .withProperty("config",
+                        "#class:" + MyConfig.class.getName() + 
"#create(\"true\")")
+                .withRemoveParameters(false).bind();
+
+        assertEquals("Donald", target.getName());
+        assertTrue(target.getConfig().isEnabled());
+
+        context.stop();
+    }
+
+    @Test
+    public void testFactoryQuotedBooleanFalse() {
+        CamelContext context = new DefaultCamelContext();
+
+        context.start();
+
+        MyAppWithConfig target = new MyAppWithConfig();
+
+        PropertyBindingSupport.build()
+                .withCamelContext(context)
+                .withTarget(target)
+                .withProperty("name", "Donald")
+                .withProperty("config",
+                        "#class:" + MyConfig.class.getName() + 
"#create('false')")
+                .withRemoveParameters(false).bind();
+
+        assertEquals("Donald", target.getName());
+        assertFalse(target.getConfig().isEnabled());
+
+        context.stop();
+    }
+
+    @Test
+    public void testFactoryQuotedBooleanIgnoreCase() {
+        CamelContext context = new DefaultCamelContext();
+
+        context.start();
+
+        MyAppWithConfig target = new MyAppWithConfig();
+
+        PropertyBindingSupport.build()
+                .withCamelContext(context)
+                .withTarget(target)
+                .withProperty("name", "Donald")
+                .withProperty("config",
+                        "#class:" + MyConfig.class.getName() + 
"#create(\"FALSE\")")
+                .withRemoveParameters(false).bind();
+
+        assertEquals("Donald", target.getName());
+        assertFalse(target.getConfig().isEnabled());
+
+        context.stop();
+    }
+
     public static class MyApp {
 
         private String name;
@@ -133,4 +201,43 @@ public class PropertyBindingSupportClassFactoryMethodTest {
         }
     }
 
+    public static class MyAppWithConfig {
+
+        private String name;
+        private MyConfig config;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public MyConfig getConfig() {
+            return config;
+        }
+
+        public void setConfig(MyConfig config) {
+            this.config = config;
+        }
+    }
+
+    public static class MyConfig {
+
+        private final boolean enabled;
+
+        private MyConfig(boolean enabled) {
+            this.enabled = enabled;
+        }
+
+        public static MyConfig create(boolean enabled) {
+            return new MyConfig(enabled);
+        }
+
+        public boolean isEnabled() {
+            return enabled;
+        }
+    }
+
 }
diff --git 
a/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportConstructorTest.java
 
b/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportConstructorTest.java
index c40664de85d0..fe11ffb5a74f 100644
--- 
a/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportConstructorTest.java
+++ 
b/core/camel-main/src/test/java/org/apache/camel/main/PropertyBindingSupportConstructorTest.java
@@ -24,6 +24,8 @@ import org.apache.camel.support.PropertyBindingSupport;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Unit test for PropertyBindingSupport
@@ -76,6 +78,72 @@ public class PropertyBindingSupportConstructorTest {
         context.stop();
     }
 
+    @Test
+    public void testConstructorQuotedBoolean() {
+        CamelContext context = new DefaultCamelContext();
+
+        context.start();
+
+        MyAppWithBoolean target = new MyAppWithBoolean();
+
+        PropertyBindingSupport.build()
+                .withCamelContext(context)
+                .withTarget(target)
+                .withProperty("name", "Donald")
+                .withProperty("config",
+                        "#class:" + MyConfig.class.getName() + "(\"true\")")
+                .withRemoveParameters(false).bind();
+
+        assertEquals("Donald", target.getName());
+        assertTrue(target.getConfig().isEnabled());
+
+        context.stop();
+    }
+
+    @Test
+    public void testConstructorQuotedBooleanFalse() {
+        CamelContext context = new DefaultCamelContext();
+
+        context.start();
+
+        MyAppWithBoolean target = new MyAppWithBoolean();
+
+        PropertyBindingSupport.build()
+                .withCamelContext(context)
+                .withTarget(target)
+                .withProperty("name", "Donald")
+                .withProperty("config",
+                        "#class:" + MyConfig.class.getName() + "('false')")
+                .withRemoveParameters(false).bind();
+
+        assertEquals("Donald", target.getName());
+        assertFalse(target.getConfig().isEnabled());
+
+        context.stop();
+    }
+
+    @Test
+    public void testConstructorQuotedBooleanIgnoreCase() {
+        CamelContext context = new DefaultCamelContext();
+
+        context.start();
+
+        MyAppWithBoolean target = new MyAppWithBoolean();
+
+        PropertyBindingSupport.build()
+                .withCamelContext(context)
+                .withTarget(target)
+                .withProperty("name", "Donald")
+                .withProperty("config",
+                        "#class:" + MyConfig.class.getName() + "(\"TRUE\")")
+                .withRemoveParameters(false).bind();
+
+        assertEquals("Donald", target.getName());
+        assertTrue(target.getConfig().isEnabled());
+
+        context.stop();
+    }
+
     public static class MyApp {
 
         private String name;
@@ -98,4 +166,39 @@ public class PropertyBindingSupportConstructorTest {
         }
     }
 
+    public static class MyAppWithBoolean {
+
+        private String name;
+        private MyConfig config;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public MyConfig getConfig() {
+            return config;
+        }
+
+        public void setConfig(MyConfig config) {
+            this.config = config;
+        }
+    }
+
+    public static class MyConfig {
+
+        private final boolean enabled;
+
+        public MyConfig(boolean enabled) {
+            this.enabled = enabled;
+        }
+
+        public boolean isEnabled() {
+            return enabled;
+        }
+    }
+
 }
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 18e6e1463209..6ccbd8ce8f27 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
@@ -1496,16 +1496,18 @@ public final class PropertyBindingSupport {
 
         // single quoted is valid
         if (value.startsWith("'") && value.endsWith("'")) {
-            return String.class;
+            String unquoted = value.substring(1, value.length() - 1);
+            return isBooleanValue(unquoted) ? Boolean.class : String.class;
         }
 
         // double quoted is valid
         if (value.startsWith("\"") && value.endsWith("\"")) {
-            return String.class;
+            String unquoted = value.substring(1, value.length() - 1);
+            return isBooleanValue(unquoted) ? Boolean.class : String.class;
         }
 
         // true or false is valid (boolean)
-        if (value.equals("true") || value.equals("false")) {
+        if (isBooleanValue(value)) {
             return Boolean.class;
         }
 
@@ -1544,6 +1546,10 @@ public final class PropertyBindingSupport {
         return null;
     }
 
+    private static boolean isBooleanValue(String value) {
+        return "true".equalsIgnoreCase(value) || 
"false".equalsIgnoreCase(value);
+    }
+
     private static boolean isParameterMatchingType(Class<?> parameterType, 
Class<?> expectedType) {
         if (Number.class.equals(parameterType)) {
             // number should match long/int/etc.

Reply via email to