jiajunwang commented on a change in pull request #688: Fix the watcher leakage 
issue
URL: https://github.com/apache/helix/pull/688#discussion_r368313478
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
 ##########
 @@ -1261,31 +1257,75 @@ private void processDataOrChildChange(WatchedEvent 
event, long notificationTime)
 
     if (event.getType() == EventType.NodeDataChanged || event.getType() == 
EventType.NodeDeleted
         || event.getType() == EventType.NodeCreated) {
+      boolean pathExists = event.getType() != EventType.NodeDeleted;
       Set<IZkDataListenerEntry> listeners = _dataListener.get(path);
       if (listeners != null && !listeners.isEmpty()) {
-        fireDataChangedEvents(event.getPath(), listeners, 
OptionalLong.of(notificationTime));
+        fireDataChangedEvents(event.getPath(), listeners, notificationTime, 
pathExists);
+      }
+    }
+  }
+
+  /**
+   * The method is called when state change occurs and we need to handle 
existing path data handlers
+   */
+  private void fireDataChangedEvents(final String path, 
Set<IZkDataListenerEntry> listeners) {
+    try {
+      for (final IZkDataListenerEntry listener : listeners) {
+        ZkEvent zkEvent = new ZkEvent(
+            "Data of " + path + " changed sent to " + 
listener.getDataListener()
+                + " prefetch data: " + listener.isPrefetchData()) {
+          @Override
+          public void run()
+              throws Exception {
+            Object data;
+            // TODO: are we fetching the data multiple times?
 
 Review comment:
   The answer is yes. There is a solution, can we do the same as the other 
methods so as to avoid multiple reads?

----------------------------------------------------------------
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]

Reply via email to