Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,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
Expand Down Expand Up @@ -3729,7 +3729,10 @@ public List<ServerName> getBackupMasters() {

@Override
public Iterator<ServerName> getBootstrapNodes() {
return bootstrapNodeManager.getBootstrapNodes().iterator();
BootstrapNodeManager manager = bootstrapNodeManager;
return manager != null
? manager.getBootstrapNodes().iterator()
: Collections.<ServerName> emptyList().iterator();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -87,6 +88,13 @@ private void assertListEquals(List<ServerName> expected, List<ServerName> actual
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 =
Expand Down