From c2e2e134555010ec28da296bcfef4ba2613a5c6c Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Mon, 11 Jan 2016 16:59:46 -0800 Subject: [PATCH] HDFS-8584. NPE in distcp when ssl configuration file does not exist in class path. Contributed by Surendra Singh Lilhore. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/tools/DistCp.java | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b03cd96e5f..f9a7dcbbea 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2584,6 +2584,9 @@ Release 2.8.0 - UNRELEASED HDFS-9639. Inconsistent Logging in BootstrapStandby. (Xiaobing Zhou via Arpit Agarwal) + HDFS-8584. NPE in distcp when ssl configuration file does not exist in + class path. (Surendra Singh Lilhore via Xiaoyu Yao) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java index f919d21152..9db2b1b1e0 100644 --- a/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java +++ b/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCp.java @@ -19,6 +19,7 @@ package org.apache.hadoop.tools; import java.io.IOException; +import java.net.URL; import java.util.Random; import org.apache.commons.logging.Log; @@ -270,8 +271,14 @@ private Job createJob() throws IOException { */ private void setupSSLConfig(Job job) throws IOException { Configuration configuration = job.getConfiguration(); - Path sslConfigPath = new Path(configuration. - getResource(inputOptions.getSslConfigurationFile()).toString()); + URL sslFileUrl = configuration.getResource(inputOptions + .getSslConfigurationFile()); + if (sslFileUrl == null) { + throw new IOException( + "Given ssl configuration file doesn't exist in class path : " + + inputOptions.getSslConfigurationFile()); + } + Path sslConfigPath = new Path(sslFileUrl.toString()); addSSLFilesToDistCache(job, sslConfigPath); configuration.set(DistCpConstants.CONF_LABEL_SSL_CONF, sslConfigPath.getName());