i3wangyi commented on a change in pull request #688: Fix the watcher leakage
issue
URL: https://github.com/apache/helix/pull/688#discussion_r372142431
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
##########
@@ -1310,26 +1318,30 @@ public void run() throws Exception {
}
private void fireChildChangedEvents(final String path, Set<IZkChildListener>
childListeners) {
+ //TODO: Use event type to check if path exists and save network request
+ boolean pathExists = exists(path);
try {
- final ZkPathStatRecord pathStatRecord = new ZkPathStatRecord(path);
for (final IZkChildListener listener : childListeners) {
_eventThread.send(new ZkEvent("Children of " + path + " changed sent
to " + listener) {
@Override
public void run() throws Exception {
- // Reinstall watch before listener callbacks to check the znode
status
- if (!pathStatRecord.pathChecked()) {
- pathStatRecord.recordPathStat(getStat(path, hasListeners(path)),
- OptionalLong.empty());
- }
- List<String> children = null;
- if (pathStatRecord.pathExists()) {
+ List<String> children = new ArrayList<>();
Review comment:
Thanks for mentioning it! You're talking about CallbackHandler's
implementation, right? I just checked you're right, that CallbackHandler does
rely on the NULL to remove the listener.
To me, it's very odd cause it obviously violates the decoupling principle
while 2 different classes are so tightly correlated, also it doesn't make sense
to pass a NULL variable.
I will put a TODO and leave the current code as it is. But still, need to
add the child exists watcher part.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]