You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2011/10/28 21:10:34 UTC

svn commit: r1190505 - /incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooLock.java

Author: ecn
Date: Fri Oct 28 19:10:34 2011
New Revision: 1190505

URL: http://svn.apache.org/viewvc?rev=1190505&view=rev
Log:
ACCUMULO-93: tighten up the lock check, ensure lock checking does not throw NPE

Modified:
    incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooLock.java

Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooLock.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooLock.java?rev=1190505&r1=1190504&r2=1190505&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooLock.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/zookeeper/ZooLock.java Fri Oct 28 19:10:34 2011
@@ -305,7 +305,7 @@ public class ZooLock implements Watcher 
     
     List<String> children = zk.getChildren(lid.path, false);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       return false;
     }
     
@@ -323,7 +323,7 @@ public class ZooLock implements Watcher 
     
     List<String> children = zc.getChildren(lid.path);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       return false;
     }
     
@@ -341,7 +341,7 @@ public class ZooLock implements Watcher 
   public static byte[] getLockData(ZooKeeper zk, String path) throws KeeperException, InterruptedException {
     List<String> children = zk.getChildren(path, false);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       return null;
     }
     
@@ -356,7 +356,7 @@ public class ZooLock implements Watcher 
     
     List<String> children = zc.getChildren(path);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       return null;
     }
     
@@ -381,7 +381,7 @@ public class ZooLock implements Watcher 
   public static long getSessionId(ZooCache zc, String path) throws KeeperException, InterruptedException {
     List<String> children = zc.getChildren(path);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       return 0;
     }
     
@@ -406,7 +406,7 @@ public class ZooLock implements Watcher 
     IZooReaderWriter zk = ZooReaderWriter.getInstance();
     children = zk.getChildren(path);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       throw new IllegalStateException("No lock is held at " + path);
     }
     
@@ -428,7 +428,7 @@ public class ZooLock implements Watcher 
     IZooReaderWriter zk = ZooReaderWriter.getInstance();
     children = zk.getChildren(path);
     
-    if (children.size() == 0) {
+    if (children == null || children.size() == 0) {
       throw new IllegalStateException("No lock is held at " + path);
     }