BewareMyPower commented on code in PR #19972:
URL: https://github.com/apache/pulsar/pull/19972#discussion_r1161415761


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1727,8 +1745,8 @@ CompletableFuture<Void> removeReplicator(String 
remoteCluster) {
 
         String name = PersistentReplicator.getReplicatorName(replicatorPrefix, 
remoteCluster);
 
-        replicators.get(remoteCluster).disconnect().thenRun(() -> {
-
+        
Optional.ofNullable(replicators.get(remoteCluster)).map(Replicator::disconnect)
+                .orElse(CompletableFuture.completedFuture(null)).thenRun(() -> 
{

Review Comment:
   I think not. See
   
   ```java
       public static <U> CompletableFuture<U> completedFuture(U value) {
           return new CompletableFuture<U>((value == null) ? NIL : value);
       }
   ```
   
   so `completedFuture(null)` won't create a new instance.



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