From 541efe18c7328ab78ae1fa42f367e309a0effb5e Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Thu, 19 Jan 2017 15:36:54 +0800 Subject: [PATCH] HDFS-11287. Storage class member storageDirs should be private to avoid unprotected access by derived classes. (Manoj Govindassamy via lei) (cherry picked from commit 63320d1daab7ce846bb180623378efe431ad8c52) --- .../java/org/apache/hadoop/hdfs/server/common/Storage.java | 4 ++-- .../hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java | 2 +- .../org/apache/hadoop/hdfs/server/datanode/DataStorage.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java index b0fe2900591..87ba99dd6b5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java @@ -123,9 +123,9 @@ public abstract class Storage extends StorageInfo { public boolean isOfType(StorageDirType type); } - protected List storageDirs = + private final List storageDirs = new CopyOnWriteArrayList<>(); - + private class DirIterator implements Iterator { final StorageDirType dirType; final boolean includeShared; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java index a7edb4b6002..c6f025582d5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java @@ -296,7 +296,7 @@ public class BlockPoolSliceStorage extends Storage { it.hasNext(); ) { StorageDirectory sd = it.next(); if (sd.getRoot().getAbsoluteFile().equals(absPathToRemove)) { - this.storageDirs.remove(sd); + getStorageDirs().remove(sd); break; } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java index c5e744f48b5..9951ed62a8b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java @@ -519,7 +519,7 @@ public class DataStorage extends Storage { bpsStorage.remove(bpRoot.getAbsoluteFile()); } - this.storageDirs.remove(sd); + getStorageDirs().remove(sd); try { sd.unlock(); } catch (IOException e) {