You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/10/14 17:38:04 UTC

[GitHub] [zookeeper] ctubbsii commented on a change in pull request #882: ZOOKEEPER-3342: Use StandardCharsets

ctubbsii commented on a change in pull request #882:
URL: https://github.com/apache/zookeeper/pull/882#discussion_r504834541



##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);

Review comment:
       Not sure why this was changed, but it should be changed back:
   
   ```suggestion
       Assert.fail();
   ```
   
   (or even better, use assertThrows instead, but that's outside the scope of this changeset)

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {
+        try {
+          takeResult[0] = queueHandles[0].take();
+        } catch (KeeperException e) {
 
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+        } catch (InterruptedException e) {
 
-        for (int i = 0; i < m; i++) {
-            queueHandles[1].remove();
         }
-        Assert.assertEquals(new String(queueHandles[1].element()), testString + m);
-    }
+      }
+    };
+    takeThread.start();
 
-    @Test
-    public void testElement1() throws Exception {
-        createNremoveMelementTest("/testElement1", 1, 0);
-    }
+    Thread.sleep(1000);
+    Thread offerThread = new Thread() {
+      public void run() {
+        try {
+          queueHandles[0].offer(testString.getBytes(UTF_8));
+        } catch (KeeperException e) {
 
-    @Test
-    public void testElement2() throws Exception {
-        createNremoveMelementTest("/testElement2", 10, 2);
-    }
+        } catch (InterruptedException e) {
 
-    @Test
-    public void testElement3() throws Exception {
-        createNremoveMelementTest("/testElement3", 1000, 500);
+        }
+      }
+    };
+    offerThread.start();
+    offerThread.join();
+
+    takeThread.join();
+
+    Assert.assertTrue(takeResult[0] != null);

Review comment:
       assertNotNull is better. This should go back to the way it was.

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {
+        try {
+          takeResult[0] = queueHandles[0].take();
+        } catch (KeeperException e) {
 
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+        } catch (InterruptedException e) {

Review comment:
       Why separate out these exceptions instead of keeping the original multi-catch? This seems like a regression.

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {
+        try {
+          takeResult[0] = queueHandles[0].take();
+        } catch (KeeperException e) {
 
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+        } catch (InterruptedException e) {
 
-        for (int i = 0; i < m; i++) {
-            queueHandles[1].remove();
         }
-        Assert.assertEquals(new String(queueHandles[1].element()), testString + m);
-    }
+      }
+    };
+    takeThread.start();
 
-    @Test
-    public void testElement1() throws Exception {
-        createNremoveMelementTest("/testElement1", 1, 0);
-    }
+    Thread.sleep(1000);
+    Thread offerThread = new Thread() {
+      public void run() {
+        try {
+          queueHandles[0].offer(testString.getBytes(UTF_8));
+        } catch (KeeperException e) {
 
-    @Test
-    public void testElement2() throws Exception {
-        createNremoveMelementTest("/testElement2", 10, 2);
-    }
+        } catch (InterruptedException e) {
 
-    @Test
-    public void testElement3() throws Exception {
-        createNremoveMelementTest("/testElement3", 1000, 500);
+        }
+      }
+    };
+    offerThread.start();
+    offerThread.join();
+
+    takeThread.join();
+
+    Assert.assertTrue(takeResult[0] != null);
+    Assert.assertEquals(new String(takeResult[0], UTF_8), testString);
+  }
+
+  @Test
+  public void testTakeWait2() throws Exception {
+    String dir = "/testTakeWait2";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
+    int numAttempts = 2;
+    for (int i = 0; i < numAttempts; i++) {
+      final byte[] takeResult[] = new byte[1][];

Review comment:
       The type of the variable is `byte[][]`, so this should go back to the way it was.

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {
+        try {
+          takeResult[0] = queueHandles[0].take();
+        } catch (KeeperException e) {
 
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+        } catch (InterruptedException e) {
 
-        for (int i = 0; i < m; i++) {
-            queueHandles[1].remove();
         }
-        Assert.assertEquals(new String(queueHandles[1].element()), testString + m);
-    }
+      }
+    };
+    takeThread.start();
 
-    @Test
-    public void testElement1() throws Exception {
-        createNremoveMelementTest("/testElement1", 1, 0);
-    }
+    Thread.sleep(1000);
+    Thread offerThread = new Thread() {
+      public void run() {
+        try {
+          queueHandles[0].offer(testString.getBytes(UTF_8));
+        } catch (KeeperException e) {
 
-    @Test
-    public void testElement2() throws Exception {
-        createNremoveMelementTest("/testElement2", 10, 2);
-    }
+        } catch (InterruptedException e) {
 
-    @Test
-    public void testElement3() throws Exception {
-        createNremoveMelementTest("/testElement3", 1000, 500);
+        }
+      }
+    };
+    offerThread.start();
+    offerThread.join();
+
+    takeThread.join();
+
+    Assert.assertTrue(takeResult[0] != null);
+    Assert.assertEquals(new String(takeResult[0], UTF_8), testString);
+  }
+
+  @Test
+  public void testTakeWait2() throws Exception {
+    String dir = "/testTakeWait2";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
+    int numAttempts = 2;
+    for (int i = 0; i < numAttempts; i++) {
+      final byte[] takeResult[] = new byte[1][];
+      final String threadTestString = testString + i;
+      Thread takeThread = new Thread() {
+        public void run() {
+          try {
+            takeResult[0] = queueHandles[0].take();
+          } catch (KeeperException e) {
+
+          } catch (InterruptedException e) {
+
+          }
+        }
+      };

Review comment:
       Another conversion of lambda/multi-catch to the old style code that should go back to the way it was. There's more below. I'll stop calling them out, but they should be changed back everywhere.

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {
+        try {
+          takeResult[0] = queueHandles[0].take();
+        } catch (KeeperException e) {
 
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+        } catch (InterruptedException e) {
 
-        for (int i = 0; i < m; i++) {
-            queueHandles[1].remove();
         }
-        Assert.assertEquals(new String(queueHandles[1].element()), testString + m);
-    }
+      }
+    };
+    takeThread.start();
 
-    @Test
-    public void testElement1() throws Exception {
-        createNremoveMelementTest("/testElement1", 1, 0);
-    }
+    Thread.sleep(1000);
+    Thread offerThread = new Thread() {
+      public void run() {
+        try {
+          queueHandles[0].offer(testString.getBytes(UTF_8));
+        } catch (KeeperException e) {
 
-    @Test
-    public void testElement2() throws Exception {
-        createNremoveMelementTest("/testElement2", 10, 2);
-    }
+        } catch (InterruptedException e) {
 
-    @Test
-    public void testElement3() throws Exception {
-        createNremoveMelementTest("/testElement3", 1000, 500);
+        }
+      }
+    };

Review comment:
       Same comments about keeping lambda and multi-catch

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();

Review comment:
       I think this creates an unused variable. You could remove the assignment, as it was before, or you can do something with it in a new Assert statement. A simple thing is just assert that it's not null.

##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/ServerAdminClient.java
##########
@@ -52,7 +53,7 @@ public static void ruok(String host, int port) {
             byte[] resBytes = new byte[4];
 
             int rc = is.read(resBytes);
-            String retv = new String(resBytes);
+            String retv = new String(resBytes, StandardCharsets.UTF_8);

Review comment:
       These would be great to use static imports for the `UTF_8`, as was done in some of the other classes.

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {
+        try {
+          takeResult[0] = queueHandles[0].take();
+        } catch (KeeperException e) {
 
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+        } catch (InterruptedException e) {
 
-        for (int i = 0; i < m; i++) {
-            queueHandles[1].remove();
         }
-        Assert.assertEquals(new String(queueHandles[1].element()), testString + m);
-    }
+      }
+    };
+    takeThread.start();
 
-    @Test
-    public void testElement1() throws Exception {
-        createNremoveMelementTest("/testElement1", 1, 0);
-    }
+    Thread.sleep(1000);
+    Thread offerThread = new Thread() {
+      public void run() {
+        try {
+          queueHandles[0].offer(testString.getBytes(UTF_8));
+        } catch (KeeperException e) {
 
-    @Test
-    public void testElement2() throws Exception {
-        createNremoveMelementTest("/testElement2", 10, 2);
-    }
+        } catch (InterruptedException e) {
 
-    @Test
-    public void testElement3() throws Exception {
-        createNremoveMelementTest("/testElement3", 1000, 500);
+        }
+      }
+    };
+    offerThread.start();
+    offerThread.join();
+
+    takeThread.join();
+
+    Assert.assertTrue(takeResult[0] != null);
+    Assert.assertEquals(new String(takeResult[0], UTF_8), testString);
+  }
+
+  @Test
+  public void testTakeWait2() throws Exception {
+    String dir = "/testTakeWait2";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
+    int numAttempts = 2;
+    for (int i = 0; i < numAttempts; i++) {
+      final byte[] takeResult[] = new byte[1][];
+      final String threadTestString = testString + i;
+      Thread takeThread = new Thread() {
+        public void run() {
+          try {
+            takeResult[0] = queueHandles[0].take();
+          } catch (KeeperException e) {
+
+          } catch (InterruptedException e) {
+
+          }
+        }
+      };
+      takeThread.start();
 
-    @Test
-    public void testElement4() throws Exception {
-        createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
-    }
+      Thread.sleep(1000);
+      Thread offerThread = new Thread() {
+        public void run() {
+          try {
+            queueHandles[0].offer(threadTestString.getBytes(UTF_8));
+          } catch (KeeperException e) {
+
+          } catch (InterruptedException e) {
 
-    @Test
-    public void testTakeWait1() throws Exception {
-        String dir = "/testTakeWait1";
-        final String testString = "Hello World";
-        final int numClients = 1;
-        final ZooKeeper[] clients = new ZooKeeper[numClients];
-        final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+          }
         }
+      };
+      offerThread.start();
+      offerThread.join();
 
-        final byte[][] takeResult = new byte[1][];
-        Thread takeThread = new Thread(() -> {
-            try {
-                takeResult[0] = queueHandles[0].take();
-            } catch (KeeperException | InterruptedException ignore) {
-                // no op
-            }
-        });
-        takeThread.start();
-
-        Thread.sleep(1000);
-        Thread offerThread = new Thread(() -> {
-            try {
-                queueHandles[0].offer(testString.getBytes());
-            } catch (KeeperException | InterruptedException ignore) {
-                // no op
-            }
-        });
-        offerThread.start();
-        offerThread.join();
-
-        takeThread.join();
-
-        Assert.assertNotNull(takeResult[0]);
-        Assert.assertEquals(new String(takeResult[0]), testString);
-    }
+      takeThread.join();
 
-    @Test
-    public void testTakeWait2() throws Exception {
-        String dir = "/testTakeWait2";
-        final String testString = "Hello World";
-        final int numClients = 1;
-        final ZooKeeper[] clients = new ZooKeeper[numClients];
-        final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-        int numAttempts = 2;
-        for (int i = 0; i < numAttempts; i++) {
-            final byte[][] takeResult = new byte[1][];
-            final String threadTestString = testString + i;
-            Thread takeThread = new Thread(() -> {
-                try {
-                    takeResult[0] = queueHandles[0].take();
-                } catch (KeeperException | InterruptedException ignore) {
-                    // no op
-                }
-            });
-            takeThread.start();
-
-            Thread.sleep(1000);
-            Thread offerThread = new Thread(() -> {
-                try {
-                    queueHandles[0].offer(threadTestString.getBytes());
-                } catch (KeeperException | InterruptedException ignore) {
-                    // no op
-                }
-            });
-            offerThread.start();
-            offerThread.join();
-
-            takeThread.join();
-
-            Assert.assertNotNull(takeResult[0]);
-            Assert.assertEquals(new String(takeResult[0]), threadTestString);
-        }
+      Assert.assertTrue(takeResult[0] != null);

Review comment:
       should go back to assertNotNull

##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/cli/ReconfigCommand.java
##########
@@ -152,7 +153,7 @@ public boolean exec() throws CliException {
             }
 
             byte[] curConfig = ((ZooKeeperAdmin) zk).reconfigure(joining, leaving, members, version, stat);
-            out.println("Committed new configuration:\n" + new String(curConfig));
+            out.println("Committed new configuration:\n" + new String(curConfig, StandardCharsets.UTF_8));

Review comment:
       This should probably just be two `println` statements instead of appending a newline and using string concatenation.

##########
File path: zookeeper-recipes/zookeeper-recipes-queue/src/test/java/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
##########
@@ -27,243 +28,260 @@
 import org.junit.Test;
 
 /**
- * Tests for {@link DistributedQueue}.
+ * DistributedQueueTest test.
  */
 public class DistributedQueueTest extends ClientBase {
 
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
+  @After
+  public void tearDown() throws Exception {
+    super.tearDown();
+  }
+
+  @Test
+  public void testOffer1() throws Exception {
+    String dir = "/testOffer1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer1() throws Exception {
-        String dir = "/testOffer1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testOffer2() throws Exception {
+    String dir = "/testOffer2";
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testOffer2() throws Exception {
-        String dir = "/testOffer2";
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[1].remove();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[1].remove();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testTake1() throws Exception {
+    String dir = "/testTake1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testTake1() throws Exception {
-        String dir = "/testTake1";
-        String testString = "Hello World";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        queueHandles[0].offer(testString.getBytes());
-
-        byte[] dequeuedBytes = queueHandles[0].take();
-        Assert.assertEquals(new String(dequeuedBytes), testString);
+    queueHandles[0].offer(testString.getBytes(UTF_8));
+
+    byte[] dequeuedBytes = queueHandles[0].take();
+    Assert.assertEquals(new String(dequeuedBytes, UTF_8), testString);
+  }
+
+  @Test
+  public void testRemove1() throws Exception {
+    String dir = "/testRemove1";
+    String testString = "Hello World";
+    final int numClients = 1;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    @Test
-    public void testRemove1() throws Exception {
-        String dir = "/testRemove1";
-        final int numClients = 1;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        try {
-            queueHandles[0].remove();
-        } catch (NoSuchElementException e) {
-            return;
-        }
-
-        Assert.fail();
+    try {
+      queueHandles[0].remove();
+    } catch (NoSuchElementException e) {
+      return;
+    }
+    Assert.assertTrue(false);
+  }
+
+  public void createNremoveMtest(String dir, int n, int m) throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMtest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
-
-        for (int i = 0; i < n; i++) {
-            String offerString = testString + i;
-            queueHandles[0].offer(offerString.getBytes());
-        }
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
+    }
 
-        byte[] data = null;
-        for (int i = 0; i < m; i++) {
-            data = queueHandles[1].remove();
-        }
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
+    }
+    Assert.assertEquals(new String(data, UTF_8), testString + (m - 1));
+  }
+
+  @Test
+  public void testRemove2() throws Exception {
+    createNremoveMtest("/testRemove2", 10, 2);
+  }
+
+  @Test
+  public void testRemove3() throws Exception {
+    createNremoveMtest("/testRemove3", 1000, 1000);
+  }
+
+  public void createNremoveMelementTest(String dir, int n, int m)
+      throws Exception {
+    String testString = "Hello World";
+    final int numClients = 2;
+    ZooKeeper[] clients = new ZooKeeper[numClients];
+    DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
+    }
 
-        Assert.assertNotNull(data);
-        Assert.assertEquals(new String(data), testString + (m - 1));
+    for (int i = 0; i < n; i++) {
+      String offerString = testString + i;
+      queueHandles[0].offer(offerString.getBytes(UTF_8));
     }
 
-    @Test
-    public void testRemove2() throws Exception {
-        createNremoveMtest("/testRemove2", 10, 2);
+    byte[] data = null;
+    for (int i = 0; i < m; i++) {
+      data = queueHandles[1].remove();
     }
-    @Test
-    public void testRemove3() throws Exception {
-        createNremoveMtest("/testRemove3", 1000, 1000);
+    Assert.assertEquals(new String(queueHandles[1].element(), UTF_8),
+        testString + m);
+  }
+
+  @Test
+  public void testElement1() throws Exception {
+    createNremoveMelementTest("/testElement1", 1, 0);
+  }
+
+  @Test
+  public void testElement2() throws Exception {
+    createNremoveMelementTest("/testElement2", 10, 2);
+  }
+
+  @Test
+  public void testElement3() throws Exception {
+    createNremoveMelementTest("/testElement3", 1000, 500);
+  }
+
+  @Test
+  public void testElement4() throws Exception {
+    createNremoveMelementTest("/testElement4", 1000, 1000 - 1);
+  }
+
+  @Test
+  public void testTakeWait1() throws Exception {
+    String dir = "/testTakeWait1";
+    final String testString = "Hello World";
+    final int numClients = 1;
+    final ZooKeeper[] clients = new ZooKeeper[numClients];
+    final DistributedQueue[] queueHandles = new DistributedQueue[numClients];
+    for (int i = 0; i < clients.length; i++) {
+      clients[i] = createClient();
+      queueHandles[i] = new DistributedQueue(clients[i], dir, null);
     }
 
-    public void createNremoveMelementTest(String dir, int n, int m) throws Exception {
-        String testString = "Hello World";
-        final int numClients = 2;
-        ZooKeeper[] clients = new ZooKeeper[numClients];
-        DistributedQueue[] queueHandles = new DistributedQueue[numClients];
-        for (int i = 0; i < clients.length; i++) {
-            clients[i] = createClient();
-            queueHandles[i] = new DistributedQueue(clients[i], dir, null);
-        }
+    final byte[] takeResult[] = new byte[1][];
+    Thread takeThread = new Thread() {
+      public void run() {

Review comment:
       Why convert lambda to an inner class? This seems like a regression.




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