You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "CalvinKirs (via GitHub)" <gi...@apache.org> on 2023/01/30 05:57:42 UTC

[GitHub] [incubator-seatunnel] CalvinKirs commented on a diff in pull request #3989: [Bug][Connector-v2][PulsarSource]Fix pulsar option topic-pattern bug.

CalvinKirs commented on code in PR #3989:
URL: https://github.com/apache/incubator-seatunnel/pull/3989#discussion_r1090200129


##########
seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/source/PulsarSource.java:
##########
@@ -213,12 +213,14 @@ private void setPartitionDiscoverer(Config config) {
         if (StringUtils.isNotBlank(topic)) {
             this.partitionDiscoverer = new TopicListDiscoverer(Arrays.asList(StringUtils.split(topic, ",")));
         }
-        String topicPattern = config.getString(TOPIC_PATTERN.key());
-        if (StringUtils.isNotBlank(topicPattern)) {
-            if (this.partitionDiscoverer != null) {
-                throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
+        if (config.hasPath(TOPIC_PATTERN.key())) {
+            String topicPattern = config.getString(TOPIC_PATTERN.key());
+            if (StringUtils.isNotBlank(topicPattern)) {
+                if (this.partitionDiscoverer != null) {
+                    throw new PulsarConnectorException(SeaTunnelAPIErrorCode.OPTION_VALIDATION_FAILED, String.format("The properties '%s' and '%s' is exclusive.", TOPIC.key(), TOPIC_PATTERN.key()));
+                }
+                this.partitionDiscoverer = new TopicPatternDiscoverer(Pattern.compile(topicPattern));
             }

Review Comment:
   If these two parameters are mutually exclusive, we should prompt the user during the check phase, not here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org