From 890238b496df1441892a562e8b5555b3e4a532d7 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ozawa Date: Sun, 19 Apr 2015 18:19:36 +0900 Subject: [PATCH] HDFS-8043. NPE in MiniDFSCluster teardown. Contributed by Brahma Reddy Battula. (cherry picked from commit 5459b241c86cc9a26fecca9a06ceaf524e48fed4) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java | 7 +++++-- .../java/org/apache/hadoop/hdfs/TestDFSClientFailover.java | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index cb421eee984..119ec117a44 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -202,6 +202,8 @@ Release 2.8.0 - UNRELEASED HDFS-7863. Missing description of some methods and parameters in javadoc of FSDirDeleteOp. (Brahma Reddy Battula via ozawa) + HDFS-8043. NPE in MiniDFSCluster teardown. (Brahma Reddy Battula via ozawa) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java index a1e0579b618..5e1560e9cb3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java @@ -1748,11 +1748,14 @@ public class MiniDFSCluster { nameNode = null; } } - if (deleteDfsDir) { + if (base_dir != null) { + if (deleteDfsDir) { base_dir.delete(); - } else { + } else { base_dir.deleteOnExit(); + } } + } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java index aa149091059..644d66d6ac9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java @@ -85,7 +85,9 @@ public class TestDFSClientFailover { @After public void tearDownCluster() throws IOException { - cluster.shutdown(); + if (cluster != null) { + cluster.shutdown(); + } } @After