zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] anmolnar commented on a change in pull request #823: ZOOKEEPER-2694:sync CLI command does not wait for result from server
Date Tue, 19 Mar 2019 02:44:38 GMT
anmolnar commented on a change in pull request #823: ZOOKEEPER-2694:sync CLI command does not
wait for result from server
URL: https://github.com/apache/zookeeper/pull/823#discussion_r266712939
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/cli/SyncCommand.java
 ##########
 @@ -55,14 +57,18 @@ public CliCommand parse(String[] cmdArgs) throws CliParseException {
     @Override
     public boolean exec() throws CliException {
         String path = args[1];
+        CountDownLatch latch = new CountDownLatch(1);
+        final int[] resultCode = new int[1];
         try {
             zk.sync(path, new AsyncCallback.VoidCallback() {
-
                 public void processResult(int rc, String path, Object ctx) {
-                    out.println("Sync returned " + rc);
+                    resultCode[0] = rc;
+                    latch.countDown();
                 }
             }, null);
-        } catch (IllegalArgumentException ex) {
+            latch.await();
+            out.println("Sync returned " + resultCode[0]);
+        } catch (IllegalArgumentException | InterruptedException ex) {
 
 Review comment:
   I don't it's handled properly here. You basically swallowing and hiding it inside a `MalformedPathException`
which is wrong.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message