poorbarcode commented on code in PR #17526: URL: https://github.com/apache/pulsar/pull/17526#discussion_r971017688
########## pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java: ########## @@ -2006,15 +2006,43 @@ public AuthorizationService getAuthorizationService() { return authorizationService; } - public CompletableFuture<Void> removeTopicFromCache(String topic) { + public CompletableFuture<Void> removeTopicFromCache(String topicNameString, Topic topic) { + if (topic == null){ + return removeTopicFutureFromCache(topicNameString, null); + } + final CompletableFuture<Optional<Topic>> createTopicFuture = topics.get(topicNameString); + // If not exists in cache, do nothing. + if (createTopicFuture == null){ + return CompletableFuture.completedFuture(null); + } + // If the future in cache is not yet complete, the topic instance in the cache is not the same with the topic + // in the argument. Do nothing. + if (!createTopicFuture.isDone()){ + return CompletableFuture.completedFuture(null); + } + return createTopicFuture.thenCompose(topicOptional -> { Review Comment: This is a good point. I have covered this logic branch: If the future in cache has exception complete, the topic instance in the cache is not the same as the @param topic, so the delete will return `success` -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org