You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by oa...@apache.org on 2021/01/15 09:31:23 UTC
[camel] branch master updated: CAMEL-16043: Fix
additionalProperties option in camel-kafka (#4891)
This is an automated email from the ASF dual-hosted git repository.
oalsafi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new bf772c5 CAMEL-16043: Fix additionalProperties option in camel-kafka (#4891)
bf772c5 is described below
commit bf772c526b27c5159909ab3750aee3b2cf471e7d
Author: Omar Al-Safi <om...@gmail.com>
AuthorDate: Fri Jan 15 10:30:58 2021 +0100
CAMEL-16043: Fix additionalProperties option in camel-kafka (#4891)
---
.../org/apache/camel/component/kafka/KafkaComponent.java | 14 +++++++-------
.../apache/camel/component/kafka/KafkaComponentTest.java | 12 ++++++------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java
index b12fd53..c10b1d0 100644
--- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java
+++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaComponent.java
@@ -49,6 +49,10 @@ public class KafkaComponent extends DefaultComponent implements SSLContextParame
throw new IllegalArgumentException("Topic must be configured on endpoint using syntax kafka:topic");
}
+ // extract the endpoint additional properties map
+ final Map<String, Object> endpointAdditionalProperties
+ = PropertiesHelper.extractProperties(parameters, "additionalProperties.");
+
KafkaEndpoint endpoint = new KafkaEndpoint(uri, this);
KafkaConfiguration copy = getConfiguration().copy();
@@ -61,13 +65,9 @@ public class KafkaComponent extends DefaultComponent implements SSLContextParame
endpoint.getConfiguration().setSslContextParameters(retrieveGlobalSslContextParameters());
}
- // extract the additional properties map
- if (PropertiesHelper.hasProperties(parameters, "additionalProperties.")) {
- final Map<String, Object> additionalProperties = endpoint.getConfiguration().getAdditionalProperties();
-
- // add and overwrite additional properties from endpoint to
- // pre-configured properties
- additionalProperties.putAll(PropertiesHelper.extractProperties(parameters, "additionalProperties."));
+ // overwrite the additional properties from the endpoint
+ if (!endpointAdditionalProperties.isEmpty()) {
+ endpoint.getConfiguration().getAdditionalProperties().putAll(endpointAdditionalProperties);
}
return endpoint;
diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaComponentTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaComponentTest.java
index 9be5b3b..6af3393 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaComponentTest.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaComponentTest.java
@@ -79,20 +79,20 @@ public class KafkaComponentTest extends CamelTestSupport {
assertEquals("broker1:12345,broker2:12566", endpoint.getConfiguration().getBrokers());
assertEquals("mytopic", endpoint.getConfiguration().getTopic());
assertEquals("com.class.Party", endpoint.getConfiguration().getPartitioner());
- assertEquals(789, endpoint.getConfiguration().getAdditionalProperties().get("extra.1"));
- assertEquals(null, endpoint.getConfiguration().getAdditionalProperties().get("extra.2"));
+ assertEquals("123", endpoint.getConfiguration().getAdditionalProperties().get("extra.1"));
+ assertEquals("test", endpoint.getConfiguration().getAdditionalProperties().get("extra.2"));
assertEquals("test.extra.3", endpoint.getConfiguration().getAdditionalProperties().get("extra.3"));
// test properties on producer keys
final Properties producerProperties = endpoint.getConfiguration().createProducerProperties();
- assertEquals("789", producerProperties.getProperty("extra.1"));
- assertEquals(null, producerProperties.getProperty("extra.2"));
+ assertEquals("123", producerProperties.getProperty("extra.1"));
+ assertEquals("test", producerProperties.getProperty("extra.2"));
assertEquals("test.extra.3", producerProperties.getProperty("extra.3"));
// test properties on consumer keys
final Properties consumerProperties = endpoint.getConfiguration().createConsumerProperties();
- assertEquals("789", consumerProperties.getProperty("extra.1"));
- assertEquals(null, consumerProperties.getProperty("extra.2"));
+ assertEquals("123", consumerProperties.getProperty("extra.1"));
+ assertEquals("test", consumerProperties.getProperty("extra.2"));
assertEquals("test.extra.3", producerProperties.getProperty("extra.3"));
}