From 5c08a8c04bf80490ba8a29779f8c906349771dd0 Mon Sep 17 00:00:00 2001 From: stack Date: Mon, 11 May 2020 20:47:23 -0700 Subject: [PATCH] HBASE-24338 [Flakey Tests] NPE in TestRaceBetweenSCPAndDTP Addendum2: make same fix for TestRaceBetweenSCPAndTRSP but in a second place (addendum 1 got first place). --- .../master/assignment/TestRaceBetweenSCPAndTRSP.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java index e1ba68c35af..a1b25e05455 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRaceBetweenSCPAndTRSP.java @@ -133,19 +133,20 @@ public class TestRaceBetweenSCPAndTRSP { AssignmentManager am = UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager(); ServerName sn = am.getRegionStates().getRegionState(region).getServerName(); + // Assign the CountDownLatches that get nulled in background threads else we NPE checking + // the static. ARRIVE_REGION_OPENING = new CountDownLatch(1); + CountDownLatch arriveRegionOpening = ARRIVE_REGION_OPENING; RESUME_REGION_OPENING = new CountDownLatch(1); - // Assign to local variable because this static gets set to null in above running thread and - // so can NPE when we check await later below. ARRIVE_GET_REGIONS_ON_SERVER = new CountDownLatch(1); - CountDownLatch cdl = ARRIVE_GET_REGIONS_ON_SERVER; + CountDownLatch arriveGetRegionsOnServer = ARRIVE_GET_REGIONS_ON_SERVER; RESUME_GET_REGIONS_ON_SERVER = new CountDownLatch(1); Future moveFuture = am.moveAsync(new RegionPlan(region, sn, sn)); - ARRIVE_REGION_OPENING.await(); + arriveRegionOpening.await(); UTIL.getMiniHBaseCluster().killRegionServer(sn); - cdl.await(); + arriveGetRegionsOnServer.await(); RESUME_REGION_OPENING.countDown(); moveFuture.get();