Jason918 commented on a change in pull request #12904:
URL: https://github.com/apache/pulsar/pull/12904#discussion_r753782206



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -3140,13 +3139,16 @@ private void 
initializeTopicSubscribeRateLimiterIfNeeded(Optional<TopicPolicies>
     private void registerTopicPolicyListener() {
         if (brokerService.pulsar().getConfig().isSystemTopicEnabled()
                 && 
brokerService.pulsar().getConfig().isTopicLevelPoliciesEnabled()) {
-            TopicName topicName = TopicName.get(topic);
-            TopicName cloneTopicName = topicName;
-            if (topicName.isPartitioned()) {
-                cloneTopicName = 
TopicName.get(topicName.getPartitionedTopicName());
-            }
+            brokerService.getPulsar().getTopicPoliciesService()
+                    
.registerListener(TopicName.getPartitionedTopicName(topic), this);
+        }
+    }
 
-            
brokerService.getPulsar().getTopicPoliciesService().registerListener(cloneTopicName,
 this);
+    private void unregisterTopicPolicyListener() {
+        if (brokerService.pulsar().getConfig().isSystemTopicEnabled()
+                && 
brokerService.pulsar().getConfig().isTopicLevelPoliciesEnabled()) {
+            brokerService.getPulsar().getTopicPoliciesService()
+                    
.unregisterListener(TopicName.getPartitionedTopicName(topic), this);

Review comment:
       I have optimized the unregister implementation in #12654.  See the last 
line of the unit test, 
   `listMap.get(topicName)` returns null instead of empty map.
   




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