kaisun2000 commented on a change in pull request #1035:
URL: https://github.com/apache/helix/pull/1035#discussion_r432290396
##########
File path:
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -1341,8 +1397,11 @@ private void fireChildChangedEvents(final String path,
Set<IZkChildListener> chi
@Override
public void run() throws Exception {
if (!pathStatRecord.pathChecked()) {
- pathStatRecord.recordPathStat(getStat(path, hasListeners(path)
&& pathExists),
- OptionalLong.empty());
+ if (!pathExists) {
+ pathStatRecord.recordPathStat(getStat(path, hasListeners(path)
&& pathExists), OptionalLong.empty());
+ } else {
+ pathStatRecord.recordPathStat(getStat(path, true, true),
OptionalLong.empty());
Review comment:
strictly, we should do this:
```java
Stat stat = null;
if (!pathExists || !hasListener(path)) {
stat = getStat(path, false); // will not install listener using
exists call
} else {
stat = getStat(path, true, true); // will install listener using
getData() call; if node not there, install nothing,
}
pathStatRecord.recordPathStat(stat, OptionalLong.empty());
```
Let me change it this way.
By in reality, Yi added hasListener() in hope that it would not leak path
from here when fireAllEvent() gets called. However, this does not really work
due to the reason I illustrated in my doc about case 1 leaking.
And in our code fireAllEvent() is the only place hasListener() will return
false. Otherwise, it is simple to reason that hasListeners(path) always return
true unless user can unsubscribeChildChange.
Any, would make this change.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]