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 2022/02/18 08:44:21 UTC
[camel] 01/02: CAMEL-17658 camel-debezium: additionalProperties are trimmed (#6960)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0e34c69a897e519f8ae6735bb520a1bca6d0c86d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Feb 18 09:43:21 2022 +0100
CAMEL-17658 camel-debezium: additionalProperties are trimmed (#6960)
---
.../PropertyBindingSupportMapKeyWithDotTest.java | 45 ++++++++++++++++++++++
.../camel/support/PropertyBindingSupport.java | 11 +-----
2 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportMapKeyWithDotTest.java b/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportMapKeyWithDotTest.java
index af172d6..2653877 100644
--- a/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportMapKeyWithDotTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/support/PropertyBindingSupportMapKeyWithDotTest.java
@@ -36,6 +36,8 @@ public class PropertyBindingSupportMapKeyWithDotTest extends ContextTestSupport
prop.put("id", "123");
prop.put("database.name", "MySQL");
prop.put("database.timezone", "CET");
+ prop.put("database.client.id", "123");
+ prop.put("database.client.type", "Basic");
Map<String, String> map = new HashMap<>();
PropertyBindingSupport.build().bind(context, map, prop);
@@ -43,6 +45,49 @@ public class PropertyBindingSupportMapKeyWithDotTest extends ContextTestSupport
assertEquals("123", map.get("id"));
assertEquals("MySQL", map.get("database.name"));
assertEquals("CET", map.get("database.timezone"));
+ assertEquals("123", map.get("database.client.id"));
+ assertEquals("Basic", map.get("database.client.type"));
+ }
+
+ @Test
+ public void testPropertiesConfigMap() throws Exception {
+ Map<String, Object> prop = new LinkedHashMap<>();
+ prop.put("id", "123");
+ prop.put("config.database.name", "MySQL");
+ prop.put("config.database.timezone", "CET");
+ prop.put("config.database.client.id", "123");
+ prop.put("config.database.client.type", "Basic");
+
+ Foo foo = new Foo();
+ PropertyBindingSupport.build().bind(context, foo, prop);
+
+ assertEquals("123", foo.getId());
+ assertEquals("MySQL", foo.getConfig().get("database.name"));
+ assertEquals("CET", foo.getConfig().get("database.timezone"));
+ assertEquals("123", foo.getConfig().get("database.client.id"));
+ assertEquals("Basic", foo.getConfig().get("database.client.type"));
+ }
+
+ public static class Foo {
+
+ private String id;
+ private Map<String, String> config;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Map<String, String> getConfig() {
+ return config;
+ }
+
+ public void setConfig(Map<String, String> config) {
+ this.config = config;
+ }
}
}
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 b0068e5..5f993d8 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
@@ -34,7 +34,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import org.apache.camel.CamelContext;
import org.apache.camel.ExtendedCamelContext;
@@ -337,14 +336,8 @@ public final class PropertyBindingSupport {
// prepare for next iterator
newTarget = prop;
newClass = newTarget.getClass();
- //do not ignore remaining parts, which was not traversed
- if (parts.length > 1 && i < parts.length - 2) {
- newName = IntStream.range(i + 1, parts.length)
- .mapToObj(j -> parts[j])
- .collect(Collectors.joining("."));
- } else {
- newName = parts[i + 1];
- }
+ // do not ignore remaining parts, which was not traversed
+ newName = Arrays.stream(parts, i + 1, parts.length).collect(Collectors.joining("."));
// if we have not yet found a configurer for the new target
if (configurer == null) {
configurer = PropertyConfigurerHelper.resolvePropertyConfigurer(camelContext, newTarget);