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



##########
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:
       In current `unregisterListener` implementation, it will make listeners 
key keep growing even thought  the listener unregister called.




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