diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 114aee45f51..6cca59fa783 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.master.LoadBalancer; import org.apache.hadoop.hbase.master.MasterServices; import org.apache.hadoop.hbase.master.RackManager; import org.apache.hadoop.hbase.master.RegionPlan; +import org.apache.hadoop.hbase.master.assignment.RegionStates; import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer.Cluster.Action.Type; import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting; import org.apache.hbase.thirdparty.com.google.common.base.Joiner; @@ -1457,8 +1458,9 @@ public abstract class BaseLoadBalancer implements LoadBalancer { // In the current set of regions even if one has region replica let us go with // getting the entire snapshot if (this.services != null && this.services.getAssignmentManager() != null) { // for tests - if (!hasRegionReplica && this.services.getAssignmentManager().getRegionStates() - .isReplicaAvailableForRegion(region)) { + RegionStates states = this.services.getAssignmentManager().getRegionStates(); + if (!hasRegionReplica && states != null && + states.isReplicaAvailableForRegion(region)) { hasRegionReplica = true; } }