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


##########
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:
   The problem is that we call whenComplete every time we invoke this method 
and only the first time we create the object and add it to the Map.
   
   So everytime we enqueue the execution. If this method is called in an 
hotpath you will see many allocations



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