Browse Source

HDFS-16838. Fix NPE in testAddRplicaProcessorForAddingReplicaInMap (#5125)

Reviewed-by: Xing Lin <xinglin@linkedin.com>
Reviewed-by: Ashutosh Gupta <ashugpt@amazon.com>
Signed-off-by: Tao Li <tomscut@apache.org>
ZanderXu 2 years ago
parent
commit
bcc3d2a20e

+ 5 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java

@@ -1138,9 +1138,11 @@ public class BlockPoolSlice {
   }
   }
 
 
   @VisibleForTesting
   @VisibleForTesting
-  public static void reInitializeAddReplicaThreadPool() {
-    addReplicaThreadPool.shutdown();
-    addReplicaThreadPool = null;
+  public synchronized static void reInitializeAddReplicaThreadPool() {
+    if (addReplicaThreadPool != null) {
+      addReplicaThreadPool.shutdown();
+      addReplicaThreadPool = null;
+    }
   }
   }
 
 
   @VisibleForTesting
   @VisibleForTesting