From 2bbc3ea1b54c25c28eb04caa48dece5cfc19d613 Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Wed, 13 Jul 2016 21:59:35 -0500 Subject: [PATCH] HDFS-10617. PendingReconstructionBlocks.size() should be synchronized. Contributed by Eric Badger. --- .../server/blockmanagement/PendingReconstructionBlocks.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java index 956e94f4df1..6628c43a52c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/PendingReconstructionBlocks.java +++ b/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. */ int size() { - return pendingReconstructions.size(); + synchronized (pendingReconstructions) { + return pendingReconstructions.size(); + } } /**