You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "qqu0127 (via GitHub)" <gi...@apache.org> on 2023/03/07 16:55:25 UTC

[GitHub] [helix] qqu0127 commented on a diff in pull request #2392: check connnect only called once

qqu0127 commented on code in PR #2392:
URL: https://github.com/apache/helix/pull/2392#discussion_r1128213437


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -2508,11 +2509,17 @@ public void connect(final long maxMsToWaitUntilConnected)
    */
   public void connect(final long maxMsToWaitUntilConnected, Watcher watcher)
       throws ZkInterruptedException, ZkTimeoutException, IllegalStateException {
+    acquireEventLock();
+
     if (isClosed()) {
       throw new IllegalStateException("ZkClient already closed!");
     }
+    if (_currentState != null) {
+      throw new IllegalStateException(
+          "ZkClient is not in init state. connect() has already been called.");

Review Comment:
   If I understand correctly, we should be releasing the lock



##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -2508,11 +2509,17 @@ public void connect(final long maxMsToWaitUntilConnected)
    */
   public void connect(final long maxMsToWaitUntilConnected, Watcher watcher)
       throws ZkInterruptedException, ZkTimeoutException, IllegalStateException {
+    acquireEventLock();
+
     if (isClosed()) {
       throw new IllegalStateException("ZkClient already closed!");
     }
+    if (_currentState != null) {
+      throw new IllegalStateException(
+          "ZkClient is not in init state. connect() has already been called.");
+    }
+

Review Comment:
   Why do we need the lock at the beginning?



-- 
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: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org