junkaixue commented on code in PR #2432:
URL: https://github.com/apache/helix/pull/2432#discussion_r1166067173


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -2921,10 +2988,47 @@ private void addChildListener(String path, 
IZkChildListener listener) {
     listeners.add(listener);
   }
 
+  private void addPersistListener(String path, Object listener) {
+    try {
+      _persistListenerMutex.lockInterruptibly();
+      if (listener instanceof IZkChildListener) {
+        addChildListener(path, (IZkChildListener) listener);
+      } else if (listener instanceof IZkDataListener) {
+        addDataListener(path, (IZkDataListener) listener);
+      }
+    } catch (InterruptedException ex) {
+      throw new ZkInterruptedException(ex);
+    } finally {
+      _persistListenerMutex.unlock();

Review Comment:
   Would it be possible to make these pieces of code generic?
   
   _mutx.lock();
   passedin method.invoke(xxxx)
   
   catch(e){}
   finally{
   _mutex.unlock();
   }
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to