瀏覽代碼

HDFS-10617. PendingReconstructionBlocks.size() should be synchronized. Contributed by Eric Badger.

Kihwal Lee 9 年之前
父節點
當前提交
2bbc3ea1b5

+ 3 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java

@@ -134,7 +134,9 @@ class PendingReconstructionBlocks {
    * The total number of blocks that are undergoing reconstruction.
    * The total number of blocks that are undergoing reconstruction.
    */
    */
   int size() {
   int size() {
-    return pendingReconstructions.size();
+    synchronized (pendingReconstructions) {
+      return pendingReconstructions.size();
+    }
   }
   }
 
 
   /**
   /**