helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject [helix] branch master updated: Fix NullPointerException in TestBatchMessage. (#580)
Date Sun, 17 Nov 2019 01:07:28 GMT
This is an automated email from the ASF dual-hosted git repository.

hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new 52cb222  Fix NullPointerException in TestBatchMessage. (#580)
52cb222 is described below

commit 52cb22282b7c93ed05ee6e582bbb641c2900992f
Author: Huizhi L <ihuizhi.lu@gmail.com>
AuthorDate: Sat Nov 16 17:07:21 2019 -0800

    Fix NullPointerException in TestBatchMessage. (#580)
    
    NullPointerException in TestBatchMessage when currentChildren is null and currentChildren.size()
is called.
    Changelist:
    Add a null check in handleChildChange().
---
 .../helix/integration/messaging/TestBatchMessage.java | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/helix-core/src/test/java/org/apache/helix/integration/messaging/TestBatchMessage.java
b/helix-core/src/test/java/org/apache/helix/integration/messaging/TestBatchMessage.java
index 52a4a9e..eac8860 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/messaging/TestBatchMessage.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/messaging/TestBatchMessage.java
@@ -45,13 +45,16 @@ import org.testng.annotations.Test;
 
 public class TestBatchMessage extends ZkTestBase {
   class TestZkChildListener implements IZkChildListener {
-    int _maxNbOfChilds = 0;
+    int _maxNumberOfChildren = 0;
 
     @Override
-    public void handleChildChange(String parentPath, List<String> currentChilds) throws
Exception {
-      System.out.println(parentPath + " has " + currentChilds.size() + " messages");
-      if (currentChilds.size() > _maxNbOfChilds) {
-        _maxNbOfChilds = currentChilds.size();
+    public void handleChildChange(String parentPath, List<String> currentChildren)
{
+      if (currentChildren == null) {
+        return;
+      }
+      System.out.println(parentPath + " has " + currentChildren.size() + " messages");
+      if (currentChildren.size() > _maxNumberOfChildren) {
+        _maxNumberOfChildren = currentChildren.size();
       }
     }
 
@@ -107,7 +110,7 @@ public class TestBatchMessage extends ZkTestBase {
     Assert.assertTrue(result);
     // Change to three is because there is an extra factory registered
     // So one extra NO_OP message send
-    Assert.assertTrue(listener._maxNbOfChilds <= 3,
+    Assert.assertTrue(listener._maxNumberOfChildren <= 3,
         "Should get no more than 2 messages (O->S and S->M)");
 
     // clean up
@@ -190,7 +193,7 @@ public class TestBatchMessage extends ZkTestBase {
     Assert.assertTrue(result);
     // Change to three is because there is an extra factory registered
     // So one extra NO_OP message send
-    Assert.assertTrue(listener._maxNbOfChilds <= 3,
+    Assert.assertTrue(listener._maxNumberOfChildren <= 3,
         "Should get no more than 2 messages (O->S and S->M)");
 
     // clean up
@@ -349,7 +352,7 @@ public class TestBatchMessage extends ZkTestBase {
         ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
             clusterName));
     Assert.assertTrue(result);
-    Assert.assertTrue(listener._maxNbOfChilds > 16,
+    Assert.assertTrue(listener._maxNumberOfChildren > 16,
         "Should see more than 16 messages at the same time (32 O->S and 32 S->M)");
 
     // clean up


Mime
View raw message