Permalink
Browse files

ZOOKEEPER-1307. zkCli.sh is exiting when an Invalid ACL exception is …

…thrown from setACL command through client (Kavita Sharma via phunt)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1301840 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent c442572 commit 745decebe29bba5a6409780c71d34ed1d17950c6 @phunt phunt committed Mar 17, 2012
View
@@ -148,6 +148,9 @@ BUGFIXES:
ZOOKEEPER-1344. ZooKeeper client multi-update command is not
considering the Chroot request (Rakesh R via phunt)
+
+ ZOOKEEPER-1307. zkCli.sh is exiting when an Invalid ACL exception is
+ thrown from setACL command through client (Kavita Sharma via phunt)
IMPROVEMENTS:
@@ -1380,7 +1380,7 @@ public Stat setACL(final String path, List<ACL> acl, int version)
SetACLRequest request = new SetACLRequest();
request.setPath(serverPath);
if (acl != null && acl.size() == 0) {
- throw new KeeperException.InvalidACLException();
+ throw new KeeperException.InvalidACLException(clientPath);
}
request.setAcl(acl);
request.setVersion(version);
@@ -604,6 +604,14 @@ protected boolean processCmd(MyCommandOptions co)
System.err.println("Node not empty: " + e.getPath());
} catch (KeeperException.NotReadOnlyException e) {
System.err.println("Not a read-only call: " + e.getPath());
+ }catch (KeeperException.InvalidACLException e) {
+ System.err.println("Acl is not valid : "+e.getPath());
+ }catch (KeeperException.NoAuthException e) {
+ System.err.println("Authentication is not valid : "+e.getPath());
+ }catch (KeeperException.BadArgumentsException e) {
+ System.err.println("Arguments are not valid : "+e.getPath());
+ }catch (KeeperException.BadVersionException e) {
+ System.err.println("version No is not valid : "+e.getPath());
}
return false;
}
@@ -17,6 +17,8 @@
*/
package org.apache.zookeeper;
+import static org.junit.Assert.*;
+
import java.io.IOException;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -314,4 +316,32 @@ public void testSetData() throws Exception {
zkMain.cl.parseCommand(cmdstring3);
Assert.assertFalse(zkMain.processZKCmd(zkMain.cl));
}
+
+ @Test
+ public void testCheckInvalidAcls() throws Exception {
+ final ZooKeeper zk = createClient();
+ ZooKeeperMain zkMain = new ZooKeeperMain(zk);
+ String cmdstring = "create -s -e /node data ip:scheme:gggsd"; //invalid acl's
+ try{
+ zkMain.executeLine(cmdstring);
+ }catch(KeeperException.InvalidACLException e){
+ fail("For Invalid ACls should not throw exception");
+ }
+ }
+
+ @Test
+ public void testDeleteWithInvalidVersionNo() throws Exception {
+ final ZooKeeper zk = createClient();
+ ZooKeeperMain zkMain = new ZooKeeperMain(zk);
+ String cmdstring = "create -s -e /node1 data ";
+ String cmdstring1 = "delete /node1 2";//invalid dataversion no
+ zkMain.executeLine(cmdstring);
+ try{
+ zkMain.executeLine(cmdstring1);
+
+ }catch(KeeperException.BadVersionException e){
+ fail("For Invalid dataversion number should not throw exception");
+ }
+ }
+
}

0 comments on commit 745dece

Please sign in to comment.