You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by xy...@apache.org on 2024/09/18 20:43:24 UTC

(helix) 24/30: Add null check for getClusterConfig()

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

xyuanlu pushed a commit to branch helix-gateway-service
in repository https://gitbox.apache.org/repos/asf/helix.git

commit f55348d270ecb5cae18d8581da3d92fff80be1da
Author: Tengfei Mu <tm...@linkedin.com>
AuthorDate: Mon Sep 9 14:46:37 2024 -0700

    Add null check for getClusterConfig()
---
 .../helix/controller/dataproviders/ResourceControllerDataProvider.java | 3 ++-
 .../apache/helix/controller/stages/CurrentStateComputationStage.java   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java b/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
index 37811d9a2..057cee155 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
@@ -188,7 +188,8 @@ public class ResourceControllerDataProvider extends BaseControllerDataProvider {
     refreshStablePartitionList(getIdealStates());
     refreshDisabledInstancesForAllPartitionsSet();
 
-    if (getClusterConfig().getGlobalMaxPartitionAllowedPerInstance() != -1) {
+    if (getClusterConfig() != null
+        && getClusterConfig().getGlobalMaxPartitionAllowedPerInstance() != -1) {
       buildSimpleCapacityMap(getClusterConfig().getGlobalMaxPartitionAllowedPerInstance());
       // Remove all cached IdealState because it is a global computation cannot partially be
       // performed for some resources. The computation is simple as well not taking too much resource
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java
index 64d113f0a..76b920874 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java
@@ -136,7 +136,8 @@ public class CurrentStateComputationStage extends AbstractBaseStage {
     }
 
     // Populate the capacity for simple CapacityNode
-    if (cache.getClusterConfig().getGlobalMaxPartitionAllowedPerInstance() != -1
+    if (cache.getClusterConfig() != null
+        && cache.getClusterConfig().getGlobalMaxPartitionAllowedPerInstance() != -1
         && cache instanceof ResourceControllerDataProvider) {
       final ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
       dataProvider.populateSimpleCapacitySetUsage(resourceToRebalance.keySet(),