This is an automated email from the ASF dual-hosted git repository. oalsafi pushed a commit to branch camel-3.7.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.7.x by this push: new 62f263b CAMEL-16043: Fix additionalProperties option in camel-kafka 62f263b is described below commit 62f263b22a91e9cec03fcd569c60358b60d015b7 Author: Omar Al-Safi <omars...@gmail.com> AuthorDate: Fri Jan 15 10:36:51 2021 +0100 CAMEL-16043: Fix additionalProperties option in camel-kafka --- .../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")); }