poorbarcode commented on code in PR #16247:
URL: https://github.com/apache/pulsar/pull/16247#discussion_r927675700


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1918,15 +1918,38 @@ public AuthorizationService getAuthorizationService() {
         return authorizationService;
     }
 
-    public CompletableFuture<Void> removeTopicFromCache(String topic) {
+    public CompletableFuture<Void> removeTopicFromCache(String 
topicNameString, Topic topic) {
+        if (topic == null){
+            return removeTopicFromCache(topicNameString);
+        }
+        final CompletableFuture<Optional<Topic>> createTopicFuture = 
getTopic(topicNameString, false);
+        return createTopicFuture.thenCompose(optionalTopic -> {
+            if (optionalTopic.isPresent() && optionalTopic.get() == topic){
+                return removeTopicFromCache(topicNameString, 
createTopicFuture);
+            }
+            // If topic is not in Cache, do nothing.
+            return CompletableFuture.completedFuture(null);
+        });

Review Comment:
   > We also should consider to avoid a topic can be closed more than once.
   
   I have appended the reason why `topic.close` was executed twice to the 
Motivation, and in this PR I've overwritten the `topic.close` to fix it. I also 
added a lock to the 'reset topic stat to UN-fenced' operation, could you review 
the code.



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