[fix][broker] Fix possible race condition in completing topic list watcher
@@ -197,7 +197,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.getRemoteAddress(), watcherId);
+ topicResources.deregisterPersistentTopicListener(watcher);
+ }
}
});
}
