Skip to content

[ISSUE #150] sink support topic tag - #151

Open
odbozhou wants to merge 1 commit into
apache:masterfrom
odbozhou:sink_support_tag
Open

[ISSUE #150] sink support topic tag#151
odbozhou wants to merge 1 commit into
apache:masterfrom
odbozhou:sink_support_tag

Conversation

@odbozhou

@odbozhou odbozhou commented May 27, 2022

Copy link
Copy Markdown
Contributor

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.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, exchange COMMA and SEMICOLON to maintain upgrade compatible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@ShannonDing

Copy link
Copy Markdown
Member

files conflicted. @odbozhou

@ShannonDing ShannonDing added the enhancement New feature or request label Aug 15, 2022

@ShannonDing ShannonDing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files conflicted.

@RockteMQ-AI

Copy link
Copy Markdown

⚠️ Merge conflict detected

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-lease

This 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 RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test changes detected alongside source modifications. Consider adding tests to cover the changes.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Review of PR #151: [ISSUE #150] sink support topic tag

Findings: 6 issue(s) identified (2 critical).
CLA: unknown

Please address the inline comments above.


Automated review by github-manager-bot

String messageQueueStr = taskConfig.getString(RuntimeConfigDefine.CONNECT_TOPICNAME);
if (StringUtils.isBlank(messageQueueStr)) {
return null;
public static Map<String, String> parseTopicList(ConnectKeyValue taskConfig) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name 'topicNameAndTagss' (double 's') is a typo that propagates through the method. Minor, but reduces readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sink support topic tag

4 participants