From 586c587b3db0bd622d74a5d4da5734c50c698061 Mon Sep 17 00:00:00 2001 From: Magesh Nandakumar Date: Fri, 4 Oct 2019 11:12:32 -0700 Subject: [PATCH] KAFKA-8974: Trim whitespaces in topic names in sink connector configs (#7442) Trim whitespaces in topic names specified in sink connector configs before subscribing to the consumer. Topic names don't allow whitespace characters, so trimming only will eliminate potential problems and will not place additional limits on topics specified in sink connectors. Author: Magesh Nandakumar Reviewers: Arjun Satish , Randall Hauch --- .../java/org/apache/kafka/connect/runtime/WorkerSinkTask.java | 1 + 1 file changed, 1 insertion(+) diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java index 79760c0bf46..9a71a6658a3 100644 --- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java +++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java @@ -287,6 +287,7 @@ class WorkerSinkTask extends WorkerTask { if (SinkConnectorConfig.hasTopicsConfig(taskConfig)) { String[] topics = taskConfig.get(SinkTask.TOPICS_CONFIG).split(","); + Arrays.setAll(topics, i -> topics[i].trim()); consumer.subscribe(Arrays.asList(topics), new HandleRebalance()); log.debug("{} Initializing and starting task for topics {}", this, topics); } else {