coderzc commented on code in PR #21885:
URL: https://github.com/apache/pulsar/pull/21885#discussion_r1449744961


##########
pulsar-common/src/main/java/org/apache/pulsar/common/topics/TopicList.java:
##########
@@ -47,13 +47,16 @@ public static List<String> filterTopics(List<String> 
original, String regex) {
     }
     public static List<String> filterTopics(List<String> original, Pattern 
topicsPattern) {
 
-        final Pattern shortenedTopicsPattern = 
topicsPattern.toString().contains(SCHEME_SEPARATOR)
-                ? 
Pattern.compile(SCHEME_SEPARATOR_PATTERN.split(topicsPattern.toString())[1]) : 
topicsPattern;
+        final Pattern shortenedTopicsPattern = 
Pattern.compile(removeTopicDomainSchema(topicsPattern.toString()));
 
         return original.stream()
                 .map(TopicName::get)
+                .filter(topicName -> {
+                    String partitionedTopicName = 
topicName.getPartitionedTopicName();
+                    String removedSchema = 
SCHEME_SEPARATOR_PATTERN.split(partitionedTopicName)[1];
+                    return 
shortenedTopicsPattern.matcher(removedSchema).matches();
+                })
                 .map(TopicName::toString)
-                .filter(topic -> 
shortenedTopicsPattern.matcher(SCHEME_SEPARATOR_PATTERN.split(topic)[1]).matches())
                 .collect(Collectors.toList());

Review Comment:
   It is best to deduplicate the results



##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PatternTopicsConsumerImplTest.java:
##########
@@ -679,6 +681,58 @@ public void 
testAutoSubscribePatterConsumerFromBrokerWatcher(boolean delayWatchi
         }
     }
 
+    @DataProvider(name= "partitioned")
+    public Object[][] partitioned(){
+        return new Object[][]{
+                {true},
+                {false}
+        };
+    }
+
+    @Test(timeOut = testTimeout, dataProvider = "partitioned")
+    public void testPreciseRegexpSubscribe(boolean partitioned) throws 
Exception {

Review Comment:
   Also need to test case when  
`enableBrokerSideSubscriptionPatternEvaluation=false`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to