Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.7.15 ZookeeperDynamicConfiguration移除Listener逻辑疑问 猜测是bug #10059

Closed
1 task done
SZFHH opened this issue May 19, 2022 · 2 comments
Closed
1 task done

Comments

@SZFHH
Copy link

SZFHH commented May 19, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Ask your question here

// ZookeeperDynamicConfiguration

@Override
protected void doRemoveListener(String pathKey, ConfigurationListener listener) {
    Set<ConfigurationListener> configurationListeners = cacheListener.getConfigurationListeners(pathKey);
    // 为什么要把整个cacheListener都删掉?
    if (CollectionUtils.isNotEmpty(configurationListeners)) {
        zkClient.removeDataListener(pathKey, cacheListener);
    }
    cacheListener.removeListener(pathKey, listener);
}

为什么删除pathKey中的一个ConfigurationListener要把整个cacheListener都删掉?这样不是相当于这个pathKey下所有的ConfigurationListener都失效了吗?

不知道是不是下面这个逻辑比较合理

@Override
protected void doRemoveListener(String pathKey, ConfigurationListener listener) {
    cacheListener.removeListener(pathKey, listener);
    Set<ConfigurationListener> configurationListeners = cacheListener.getConfigurationListeners(pathKey);
    if (CollectionUtils.isEmpty(configurationListeners)) {
        zkClient.removeDataListener(pathKey, cacheListener);
    }
}
@wangchengming666
Copy link
Member

yes, you are right, i will fix it.

@CrazyHZM
Copy link
Member

CrazyHZM commented Jun 6, 2022

Resolved in #10106

@CrazyHZM CrazyHZM closed this as completed Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants