Browse Source

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 <magesh.n.kumar@gmail.com>
Reviewers: Arjun Satish <arjun@confluent.io>, Randall Hauch <rhauch@gmail.com>
pull/7447/head
Magesh Nandakumar 5 years ago committed by Randall Hauch
parent
commit
586c587b3d
  1. 1
      connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java

1
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerSinkTask.java

@ -287,6 +287,7 @@ class WorkerSinkTask extends WorkerTask { @@ -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 {

Loading…
Cancel
Save