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 //Overwrite any info stored by table, this takes precedence
try { try {
if(ZKUtil.checkExists(watcher, groupBasePath) != -1) { 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)); byte[] data = ZKUtil.getData(watcher, ZNodePaths.joinZNode(groupBasePath, znode));
if(data.length > 0) { if(data.length > 0) {
ProtobufUtil.expectPBMagicPrefix(data); ProtobufUtil.expectPBMagicPrefix(data);

View File

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