hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerry...@apache.org
Subject hbase git commit: HBASE-16732 Avoid possible NPE in MetaTableLocator
Date Thu, 29 Sep 2016 21:04:41 GMT
Repository: hbase
Updated Branches:
  refs/heads/master bf3c928b7 -> 3757da643


HBASE-16732 Avoid possible NPE in MetaTableLocator


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3757da64
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3757da64
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3757da64

Branch: refs/heads/master
Commit: 3757da643d43bf0eaf8a0bd4c30b56f24c95fb6c
Parents: bf3c928
Author: Jerry He <jerryjch@apache.org>
Authored: Thu Sep 29 13:44:59 2016 -0700
Committer: Jerry He <jerryjch@apache.org>
Committed: Thu Sep 29 14:00:46 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/zookeeper/MetaTableLocator.java       | 13 ++++++++-----
 .../hadoop/hbase/zookeeper/ZooKeeperWatcher.java       |  8 +++++---
 2 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3757da64/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
index 359617a..7b64e0c 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java
@@ -550,17 +550,20 @@ public class MetaTableLocator {
       final long timeout, Configuration conf)
           throws InterruptedException {
     int numReplicasConfigured = 1;
+
+    List<ServerName> servers = new ArrayList<ServerName>();
+    // Make the blocking call first so that we do the wait to know
+    // the znodes are all in place or timeout.
+    ServerName server = blockUntilAvailable(zkw, timeout);
+    if (server == null) return null;
+    servers.add(server);
+
     try {
       List<String> metaReplicaNodes = zkw.getMetaReplicaNodes();
       numReplicasConfigured = metaReplicaNodes.size();
     } catch (KeeperException e) {
       LOG.warn("Got ZK exception " + e);
     }
-    List<ServerName> servers = new ArrayList<ServerName>(numReplicasConfigured);
-    ServerName server = blockUntilAvailable(zkw, timeout);
-    if (server == null) return null;
-    servers.add(server);
-
     for (int replicaId = 1; replicaId < numReplicasConfigured; replicaId++) {
       // return all replica locations for the meta
       servers.add(getMetaRegionLocation(zkw, replicaId));

http://git-wip-us.apache.org/repos/asf/hbase/blob/3757da64/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
index f7d7e26..1f3afe4 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
@@ -481,9 +481,11 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable
{
   public List<String> getMetaReplicaNodes() throws KeeperException {
     List<String> childrenOfBaseNode = ZKUtil.listChildrenNoWatch(this, baseZNode);
     List<String> metaReplicaNodes = new ArrayList<String>(2);
-    String pattern = conf.get("zookeeper.znode.metaserver","meta-region-server");
-    for (String child : childrenOfBaseNode) {
-      if (child.startsWith(pattern)) metaReplicaNodes.add(child);
+    if (childrenOfBaseNode != null) {
+      String pattern = conf.get("zookeeper.znode.metaserver","meta-region-server");
+      for (String child : childrenOfBaseNode) {
+        if (child.startsWith(pattern)) metaReplicaNodes.add(child);
+      }
     }
     return metaReplicaNodes;
   }


Mime
View raw message