From d95dd33ea115cb3fba25688279a5c9bbaa769da9 Mon Sep 17 00:00:00 2001 From: paulward24 <52216289+paulward24@users.noreply.github.com> Date: Mon, 1 Jul 2019 13:54:49 -0700 Subject: [PATCH] HDFS-14610. HashMap is not thread safe. Field storageMap is typically synchronized by storageMap. However, in one place, field storageMap is not protected with synchronized. (#1015) (cherry picked from commit d8bac50e12d243ef8fd2c7e0ce5c9997131dee74) (cherry picked from commit 76a91359475444cb6d415e5056430c0e743b88ee) --- .../hdfs/server/blockmanagement/DatanodeDescriptor.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java index 46a4a7e1080..a4e43f2e1ed 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java @@ -451,8 +451,11 @@ public class DatanodeDescriptor extends DatanodeInfo { this.volumeFailureSummary = volumeFailureSummary; for (StorageReport report : reports) { - DatanodeStorageInfo storage = - storageMap.get(report.getStorage().getStorageID()); + DatanodeStorageInfo storage = null; + synchronized (storageMap) { + storage = + storageMap.get(report.getStorage().getStorageID()); + } if (checkFailedStorages) { failedStorageInfos.remove(storage); }