Skip to content

Commit cd51da1

Browse files
committed
HBASE-26941 LocalHBaseCluster.waitOnRegionServer should not call join while interrupted (#4352)
Signed-off-by: Xin Sun <[email protected]> (cherry picked from commit 35aa57e)
1 parent 450a54b commit cd51da1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,20 @@ public String waitOnRegionServer(int serverNumber) {
310310
* @return Name of region server that just went down.
311311
*/
312312
public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst) {
313+
boolean interrupted = false;
313314
while (rst.isAlive()) {
314315
try {
315316
LOG.info("Waiting on " + rst.getRegionServer().toString());
316317
rst.join();
317318
} catch (InterruptedException e) {
318-
e.printStackTrace();
319+
LOG.error("Interrupted while waiting for {} to finish. Retrying join", rst.getName(), e);
320+
interrupted = true;
319321
}
320322
}
321323
regionThreads.remove(rst);
324+
if (interrupted) {
325+
Thread.currentThread().interrupt();
326+
}
322327
return rst.getName();
323328
}
324329

@@ -382,15 +387,21 @@ public String waitOnMaster(int serverNumber) {
382387
* @return Name of master that just went down.
383388
*/
384389
public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) {
390+
boolean interrupted = false;
385391
while (masterThread.isAlive()) {
386392
try {
387393
LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString());
388394
masterThread.join();
389395
} catch (InterruptedException e) {
390-
e.printStackTrace();
396+
LOG.error("Interrupted while waiting for {} to finish. Retrying join",
397+
masterThread.getName(), e);
398+
interrupted = true;
391399
}
392400
}
393401
masterThreads.remove(masterThread);
402+
if (interrupted) {
403+
Thread.currentThread().interrupt();
404+
}
394405
return masterThread.getName();
395406
}
396407

0 commit comments

Comments
 (0)