zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r1301842 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/ZooKeeper.java src/java/main/org/apache/zookeeper/ZooKeeperMain.java src/java/test/org/apache/zookeeper/ZooKeeperTest.java
Date Sat, 17 Mar 2012 00:40:44 GMT
Author: phunt
Date: Sat Mar 17 00:40:43 2012
New Revision: 1301842

URL: http://svn.apache.org/viewvc?rev=1301842&view=rev
Log:
ZOOKEEPER-1307. zkCli.sh is exiting when an Invalid ACL exception is thrown from setACL command
through client (Kavita Sharma via phunt)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeper.java
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1301842&r1=1301841&r2=1301842&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Sat Mar 17 00:40:43 2012
@@ -20,6 +20,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:
 
   ZOOKEEPER-1389. it would be nice if start-foreground used exec $JAVA

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeper.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeper.java?rev=1301842&r1=1301841&r2=1301842&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeper.java (original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeper.java Sat Mar
17 00:40:43 2012
@@ -1380,7 +1380,7 @@ public class ZooKeeper {
         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);

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java?rev=1301842&r1=1301841&r2=1301842&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java (original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java Sat
Mar 17 00:40:43 2012
@@ -604,6 +604,14 @@ public class ZooKeeperMain {
             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;
     }

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java?rev=1301842&r1=1301841&r2=1301842&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java (original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java Sat
Mar 17 00:40:43 2012
@@ -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;
@@ -148,4 +150,32 @@ public class ZooKeeperTest extends Clien
         Assert.assertEquals("ls is not taken as first argument", zkMain.cl.getCmdArgument(0),
"ls");
         Assert.assertEquals("/ is not taken as second argument", zkMain.cl.getCmdArgument(1),
"/");
     }
+
+    @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");
+            }
+    }
+
 }



Mime
View raw message