This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.11 by this push:
     new 8f5eba2815d [fix][broker] Fix possible race condition in completing 
topic list watcher (#18624)
8f5eba2815d is described below

commit 8f5eba2815d872377d2dafbd74919ab6a3775914
Author: Lari Hotari <[email protected]>
AuthorDate: Fri Nov 25 09:57:09 2022 +0200

    [fix][broker] Fix possible race condition in completing topic list watcher 
(#18624)
    
    - also apply #22686 changes since that has also been cherry-picked to 
branch-2.11
    
    (cherry picked from commit 889966c6a201ac2978022087fb049f52178b955d)
---
 .../java/org/apache/pulsar/broker/service/TopicListService.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
index 92179731683..023f1f706c4 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicListService.java
@@ -211,7 +211,11 @@ public class TopicListService {
                     if (exception != null) {
                         watcherFuture.completeExceptionally(exception);
                     } else {
-                        watcherFuture.complete(watcher);
+                        if (!watcherFuture.complete(watcher)) {
+                            log.warn("[{}] Watcher future was already 
completed. Deregistering watcherId={}.",
+                                    connection.toString(), watcherId);
+                            
topicResources.deregisterPersistentTopicListener(watcher);
+                        }
                     }
                 });
     }

Reply via email to