You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ps...@apache.org on 2026/08/27 13:45:56 UTC

(hbase) branch branch-3.0 updated: HBASE-30099 Avoid NPE when GetBootstrapNodes RPC arrives during startup (#8483)

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

petersomogyi pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 43c04bf570e HBASE-30099 Avoid NPE when GetBootstrapNodes RPC arrives during startup (#8483)
43c04bf570e is described below

commit 43c04bf570e45840cadae8b006abb0f6f225fd44
Author: Ma Zhengxuan <49...@users.noreply.github.com>
AuthorDate: Thu Aug 27 21:19:38 2026 +0800

    HBASE-30099 Avoid NPE when GetBootstrapNodes RPC arrives during startup (#8483)
    
    Co-authored-by: mazhengxuan <ma...@didiglobal.com>
    Signed-off-by: Peter Somogyi <ps...@apache.org>
    (cherry picked from commit df76c46e8ed7c2f81948b254a68ae98ebe064ed3)
---
 .../java/org/apache/hadoop/hbase/regionserver/HRegionServer.java  | 5 +++--
 .../hadoop/hbase/regionserver/TestBootstrapNodeManager.java       | 8 ++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 0874b808e68..dd4d55b7d45 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -469,7 +469,7 @@ public class HRegionServer extends HBaseServerBase<RSRpcServices>
 
   private FileSystemUtilizationChore fsUtilizationChore;
 
-  private BootstrapNodeManager bootstrapNodeManager;
+  private volatile BootstrapNodeManager bootstrapNodeManager;
 
   /**
    * True if this RegionServer is coming up in a cluster where there is no Master; means it needs to
@@ -3686,7 +3686,8 @@ public class HRegionServer extends HBaseServerBase<RSRpcServices>
 
   @Override
   public Iterator<ServerName> getBootstrapNodes() {
-    return bootstrapNodeManager.getBootstrapNodes().iterator();
+    BootstrapNodeManager manager = bootstrapNodeManager;
+    return manager != null ? manager.getBootstrapNodes().iterator() : Collections.emptyIterator();
   }
 
   @Override
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBootstrapNodeManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBootstrapNodeManager.java
index 40056c70cf2..d140a7e2f68 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBootstrapNodeManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBootstrapNodeManager.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver;
 import static org.hamcrest.CoreMatchers.hasItems;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.atLeast;
@@ -87,6 +88,13 @@ public class TestBootstrapNodeManager {
     assertThat(actual, hasItems(expected.toArray(new ServerName[0])));
   }
 
+  @Test
+  public void testGetBootstrapNodesBeforeInitialization() {
+    HRegionServer regionServer = mock(HRegionServer.class);
+    when(regionServer.getBootstrapNodes()).thenCallRealMethod();
+    assertFalse(regionServer.getBootstrapNodes().hasNext());
+  }
+
   @Test
   public void testNormal() throws Exception {
     List<ServerName> regionServers =