Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public CliCommand parse(String[] cmdArgs) throws CliParseException {
} catch (IllegalArgumentException e) {
throw new CliParseException(getUsageStr());
}
} else {
mode = defaultMode;
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,21 @@ public void testSetAclRecursive() throws Exception {
assertEquals(Ids.OPEN_ACL_UNSAFE, zk.getACL("/e", new Stat()));
}

@Test
public void testAddWatchWithoutModeUsesDefaultMode() throws Exception {
final ZooKeeper zk = createClient();
ZooKeeperMain zkMain = new ZooKeeperMain(zk);

zkMain.cl.parseCommand("addWatch -m PERSISTENT /a");
zkMain.processZKCmd(zkMain.cl);
// the command instance is shared, so the mode of the previous invocation must not leak
zkMain.cl.parseCommand("addWatch /b");
zkMain.processZKCmd(zkMain.cl);

assertEquals(Arrays.asList("/a"), zk.getPersistentWatches());
assertEquals(Arrays.asList("/b"), zk.getPersistentRecursiveWatches());
}

@Test
public void testClientReconnectWithZKClientConfig() throws Exception {
ZooKeeper zk = null;
Expand Down