SAMZA-1279: Do not process onProcessorChange if list of children is null.
authorBoris Shkolnik <boryas@apache.org>
Wed, 10 May 2017 23:57:42 +0000 (16:57 -0700)
committerXinyu Liu <xiliu@xiliu-ld.linkedin.biz>
Wed, 10 May 2017 23:57:42 +0000 (16:57 -0700)
Author: Boris Shkolnik <boryas@apache.org>

Reviewers: Navina Ramesh <navina@apache.org>

Closes #180 from sborya/NPEinCaseOfZKException

samza-core/src/main/java/org/apache/samza/zk/ZkControllerImpl.java

index 7821ef9..0b831f8 100644 (file)
@@ -94,6 +94,13 @@ public class ZkControllerImpl implements ZkController {
      */
     @Override
     public void handleChildChange(String parentPath, List<String> currentChildren) throws Exception {
+      if (currentChildren == null) {
+        // this may happen only in case of exception in ZK. It happens if the zkNode has been deleted.
+        // So the notification will pass 'null' as the list of children. Exception should be visible in the logs.
+        // It makes no sense to pass it further down.
+        LOG.error("handleChildChange on path " + parentPath + " was invoked with NULL list of children");
+        return;
+      }
       LOG.info(
           "ZkControllerImpl::ProcessorChangeHandler::handleChildChange - Path: " + parentPath + "  Current Children: "
               + currentChildren);