HBASE-20419 Fix potential NPE in ZKUtil#listChildrenAndWatchForNewChildren callers

Signed-off-by: Yu Li <liyu@apache.org>
This commit is contained in:
lujie 2018-04-16 16:01:49 +08:00 committed by Yu Li
parent 125767b44e
commit 1339ff9666
2 changed files with 11 additions and 3 deletions

View File

@ -354,7 +354,11 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
//Overwrite any info stored by table, this takes precedence
try {
if(ZKUtil.checkExists(watcher, groupBasePath) != -1) {
for(String znode: ZKUtil.listChildrenAndWatchForNewChildren(watcher, groupBasePath)) {
List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(watcher, groupBasePath);
if (children == null) {
return RSGroupInfoList;
}
for(String znode: children) {
byte[] data = ZKUtil.getData(watcher, ZNodePaths.joinZNode(groupBasePath, znode));
if(data.length > 0) {
ProtobufUtil.expectPBMagicPrefix(data);

View File

@ -135,8 +135,12 @@ public class ZKProcedureMemberRpcs implements ProcedureMemberRpcs {
LOG.debug("Checking for aborted procedures on node: '" + zkController.getAbortZnode() + "'");
try {
// this is the list of the currently aborted procedues
for (String node : ZKUtil.listChildrenAndWatchForNewChildren(zkController.getWatcher(),
zkController.getAbortZnode())) {
List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(zkController.getWatcher(),
zkController.getAbortZnode());
if (children == null || children.isEmpty()) {
return;
}
for (String node : children) {
String abortNode = ZNodePaths.joinZNode(zkController.getAbortZnode(), node);
abort(abortNode);
}