This is an automated email from the ASF dual-hosted git repository.

xyuanlu 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 bf80a543c Fix TestCloudEventCallbackProperty flaky test (#2704)
bf80a543c is described below

commit bf80a543c5c51134cfa49eab3292d265355b9068
Author: Grant Paláu Spencer <[email protected]>
AuthorDate: Mon Nov 27 11:33:13 2023 -0800

    Fix TestCloudEventCallbackProperty flaky test (#2704)
    
    Add NPE protection for test cleanup method
---
 .../event/TestCloudEventCallbackProperty.java      | 25 ++++++++++------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git 
a/helix-core/src/test/java/org/apache/helix/cloud/event/TestCloudEventCallbackProperty.java
 
b/helix-core/src/test/java/org/apache/helix/cloud/event/TestCloudEventCallbackProperty.java
index 1f345bcff..0104f88bf 100644
--- 
a/helix-core/src/test/java/org/apache/helix/cloud/event/TestCloudEventCallbackProperty.java
+++ 
b/helix-core/src/test/java/org/apache/helix/cloud/event/TestCloudEventCallbackProperty.java
@@ -58,21 +58,18 @@ public class TestCloudEventCallbackProperty {
   }
 
   @AfterTest
-  public void afterTest() {
+  public void cleanupCallbackProperty() {
     _helixManager.disconnect();
-    _cloudProperty.getCloudEventCallbackProperty()
-        .setHelixOperationEnabled(HelixOperation.ENABLE_DISABLE_INSTANCE, 
false);
-    _cloudProperty.getCloudEventCallbackProperty()
-        .setHelixOperationEnabled(HelixOperation.MAINTENANCE_MODE, false);
-    _cloudProperty.getCloudEventCallbackProperty()
-        .unregisterUserDefinedCallback(UserDefinedCallbackType.PRE_ON_PAUSE);
-    _cloudProperty.getCloudEventCallbackProperty()
-        .unregisterUserDefinedCallback(UserDefinedCallbackType.POST_ON_PAUSE);
-    _cloudProperty.getCloudEventCallbackProperty()
-        .unregisterUserDefinedCallback(UserDefinedCallbackType.PRE_ON_RESUME);
-    _cloudProperty.getCloudEventCallbackProperty()
-        .unregisterUserDefinedCallback(UserDefinedCallbackType.POST_ON_RESUME);
+    CloudEventCallbackProperty callbackProperty = 
_cloudProperty.getCloudEventCallbackProperty();
     MockCloudEventCallbackImpl.triggeredOperation.clear();
+    if (callbackProperty != null) {
+      
callbackProperty.setHelixOperationEnabled(HelixOperation.ENABLE_DISABLE_INSTANCE,
 false);
+      
callbackProperty.setHelixOperationEnabled(HelixOperation.MAINTENANCE_MODE, 
false);
+      
callbackProperty.unregisterUserDefinedCallback(UserDefinedCallbackType.PRE_ON_PAUSE);
+      
callbackProperty.unregisterUserDefinedCallback(UserDefinedCallbackType.POST_ON_PAUSE);
+      
callbackProperty.unregisterUserDefinedCallback(UserDefinedCallbackType.PRE_ON_RESUME);
+      
callbackProperty.unregisterUserDefinedCallback(UserDefinedCallbackType.POST_ON_RESUME);
+    }
   }
 
   @Test
@@ -134,7 +131,7 @@ public class TestCloudEventCallbackProperty {
 
   @Test
   public void testUserDefinedCallback() throws Exception {
-    afterTest();
+    cleanupCallbackProperty();
     // Cloud event callback property
     CloudEventCallbackProperty property = new 
CloudEventCallbackProperty(Collections
         
.singletonMap(CloudEventCallbackProperty.UserArgsInputKey.CALLBACK_IMPL_CLASS_NAME,

Reply via email to