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/01/09 10:55:50 UTC
[camel] branch camel-3.14.x updated: CAMEL-17367: camel-kafka - Using toD should strip leading slashes in extracting topicName
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.14.x by this push:
new b5ac74e CAMEL-17367: camel-kafka - Using toD should strip leading slashes in extracting topicName
b5ac74e is described below
commit b5ac74e85a12732b0492c4cc097776af362e4b21
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Jan 9 11:54:18 2022 +0100
CAMEL-17367: camel-kafka - Using toD should strip leading slashes in extracting topicName
---
.../org/apache/camel/component/kafka/KafkaSendDynamicAware.java | 7 ++++++-
.../org/apache/camel/component/kafka/integration/KafkaToDIT.java | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaSendDynamicAware.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaSendDynamicAware.java
index 0f46822..27eda63 100644
--- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaSendDynamicAware.java
+++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaSendDynamicAware.java
@@ -111,10 +111,15 @@ public class KafkaSendDynamicAware extends ServiceSupport implements SendDynamic
// topic name is after first colon
pos = uri.indexOf(':');
if (pos != -1) {
- return uri.substring(pos + 1);
+ uri = uri.substring(pos + 1);
} else {
return null;
}
+ if (uri.startsWith("//")) {
+ // strip leading slashes
+ uri = uri.substring(2);
+ }
+ return uri;
}
}
diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
index 058f856..5037895 100644
--- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
+++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
@@ -39,7 +39,7 @@ public class KafkaToDIT extends BaseEmbeddedKafkaTestSupport {
@Override
public void configure() throws Exception {
// route message dynamic using toD
- from("direct:start").toD("kafka:${header.where}");
+ from("direct:start").toD("kafka://${header.where}");
}
};
}