From c17cd4f7c163cf97d6e42865df25709f29d39e3d Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Mon, 20 Apr 2015 14:58:04 +0530 Subject: [PATCH] HDFS-8173. NPE thrown at DataNode shutdown when HTTP server was not able to create (Contributed by surendra singh lilhore) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/datanode/DataNode.java | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 9bb1fd42a7d..8dec32e4b2d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -526,6 +526,9 @@ Release 2.8.0 - UNRELEASED HDFS-8043. NPE in MiniDFSCluster teardown. (Brahma Reddy Battula via ozawa) + HDFS-8173. NPE thrown at DataNode shutdown when HTTP server was not able to + create (surendra singh lilhore via vinayakumarb) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 0ddb99c2766..e81da521ac6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -1721,10 +1721,12 @@ public class DataNode extends ReconfigurableBase LOG.warn("Exception shutting down DataNode", e); } } - try { - httpServer.close(); - } catch (Exception e) { - LOG.warn("Exception shutting down DataNode HttpServer", e); + if (httpServer != null) { + try { + httpServer.close(); + } catch (Exception e) { + LOG.warn("Exception shutting down DataNode HttpServer", e); + } } if (pauseMonitor != null) {