eolivelli commented on code in PR #20561:
URL: https://github.com/apache/pulsar/pull/20561#discussion_r1226596488


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1091,6 +1091,9 @@ public CompletableFuture<Optional<Topic>> getTopic(final 
TopicName topicName, bo
                     }
                 });
             }
+            final CompletableFuture<Optional<Topic>> topicFutureToRemove = 
topicFuture;
+            topicFuture.whenComplete((ignore, ex) -> 
topics.remove(topicName.toString(), topicFutureToRemove));

Review Comment:
   please note that you are appending a new whenComplete listener every time 
this method is called and the object is already in the map.
   we have to call "whenComplete" only if the body of  the lambda expression in 
computeIfAbsent is executed.
   I know that it sounds ugly, but we must to it



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