[ISSUE #150] sink support topic tag - #151
Conversation
| List<String> topicTagList = Splitter.on(COMMA).omitEmptyStrings().trimResults().splitToList(topicNameAndTagss); | ||
| Map<String, String> topicNameAndTagssMap = new HashMap<>(8); | ||
| for (String topicTagPair : topicTagList) { | ||
| List<String> topicAndTag = Splitter.on(SEMICOLON).omitEmptyStrings().trimResults().splitToList(topicTagPair); |
There was a problem hiding this comment.
IMO, exchange COMMA and SEMICOLON to maintain upgrade compatible.
There was a problem hiding this comment.
When there is no tag, if you configure multiple topics, it should be topic1, topic2, topic3. If there is a tag, it should be topic1;tag1, topic2;tag2, topic3;tag3, if so, is there no compatibility problem?
|
files conflicted. @odbozhou |
|
This PR has conflicts with the base branch and cannot be merged. Please rebase or merge the base branch into your branch and resolve the conflicts: git fetch origin
git checkout sink_support_tag
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR modifies 2 file(s) with 76 lines of diff. No test changes detected — consider adding test coverage.
Automated review by github-manager-bot
| @@ -19,25 +19,30 @@ | |||
| package org.apache.rocketmq.connect.runtime.config; | |||
There was a problem hiding this comment.
No test changes detected alongside source modifications. Consider adding tests to cover the changes.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
PR received and logged for review. This PR requires detailed code review by a maintainer.
Diff size: 76 lines
Author: odbozhou (CONTRIBUTOR)
Automated review by RockteMQ-AI
| String messageQueueStr = taskConfig.getString(RuntimeConfigDefine.CONNECT_TOPICNAME); | ||
| if (StringUtils.isBlank(messageQueueStr)) { | ||
| return null; | ||
| public static Map<String, String> parseTopicList(ConnectKeyValue taskConfig) { |
There was a problem hiding this comment.
No null/blank check on topicNameAndTagss before passing to Splitter. If the config key is absent or blank, Splitter.on(COMMA).splitToList(null) will throw a NullPointerException. The old code guarded with StringUtils.isBlank and returned null; that guard was removed without replacement.
| String topicNameAndTagss = taskConfig.getString(RuntimeConfigDefine.CONNECT_TOPICNAME); | ||
| List<String> topicTagList = Splitter.on(COMMA).omitEmptyStrings().trimResults().splitToList(topicNameAndTagss); | ||
| Map<String, String> topicNameAndTagssMap = new HashMap<>(8); | ||
| for (String topicTagPair : topicTagList) { |
There was a problem hiding this comment.
When a topic-tag pair contains more than two SEMICOLON-separated segments (e.g. 'topicA;tag1;tag2'), the extra segments are silently discarded and only the first tag is used. There is no validation or error reported, which could hide misconfigured connector configs.
| import org.apache.rocketmq.connect.runtime.common.ConnectKeyValue; | ||
|
|
||
| public class SinkConnectorConfig extends ConnectConfig { | ||
|
|
There was a problem hiding this comment.
The separator semantics have been swapped from the previous version: topics were previously split by SEMICOLON, now they are split by COMMA, and SEMICOLON now separates topic from tag. This is a backward-incompatible configuration format change. Any existing deployment using SEMICOLON-delimited topic lists will silently treat the entire string as one topic name, breaking existing connectors without any warning or migration path.
| try { | ||
| shouldStopPullMsg(); | ||
| pullResult = consumer.pullBlockIfNotFound(entry.getKey(), "*", entry.getValue(), MAX_MESSAGE_NUM); | ||
| pullResult = consumer.pullBlockIfNotFound(entry.getKey(), topicTagMap.get(entry.getKey().getTopic()), entry.getValue(), MAX_MESSAGE_NUM); |
There was a problem hiding this comment.
topicTagMap.get(entry.getKey().getTopic()) can return null if the MessageQueue's topic is not present in the map (e.g. dynamically assigned queues or rebalance edge cases). Passing null as the subscription expression to pullBlockIfNotFound will likely cause an NPE or an unfiltered pull depending on the client implementation, and is not equivalent to '*'.
| @@ -273,7 +275,8 @@ private void setQueueOffset() { | |||
| } | |||
|
|
|||
| private void registTopics() { | |||
There was a problem hiding this comment.
topicTagMap is assigned in registTopics() but read in pullMessageFromQueues(). If pullMessageFromQueues() is ever called before registTopics() (e.g. due to a future refactor or concurrent access), it will throw a NullPointerException. The field should be initialized to an empty map or the access should be guarded.
| import org.apache.rocketmq.connect.runtime.common.ConnectKeyValue; | ||
|
|
||
| public class SinkConnectorConfig extends ConnectConfig { | ||
|
|
There was a problem hiding this comment.
The variable name 'topicNameAndTagss' (double 's') is a typo that propagates through the method. Minor, but reduces readability.
What is the purpose of the change
close #150
Brief changelog
XX
Verifying this change
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyleto make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.