From d8bac50e12d243ef8fd2c7e0ce5c9997131dee74 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) --- .../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 6aa23765c76..e0d85586115 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); }