From 6a76250b39f33466bdc8dabab33070c90aa1a389 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Tue, 16 Jun 2015 13:52:50 -0700 Subject: [PATCH] HDFS-8548. Minicluster throws NPE on shutdown. Contributed by surendra singh lilhore. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/blockmanagement/BlocksMap.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b921f2c916..c8c36e6440 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -900,6 +900,9 @@ Release 2.8.0 - UNRELEASED HDFS-8592. SafeModeException never get unwrapped. (wheat9) + HDFS-8548. Minicluster throws NPE on shutdown. + (surendra singh lilhore via xyao) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlocksMap.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlocksMap.java index 9eb1059b3a..0dbf4858b7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlocksMap.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlocksMap.java @@ -198,7 +198,11 @@ boolean removeNode(Block b, DatanodeDescriptor node) { } int size() { - return blocks.size(); + if (blocks != null) { + return blocks.size(); + } else { + return 0; + } } Iterable getBlocks() {