HDFS-8584. NPE in distcp when ssl configuration file does not exist in class path. Contributed by Surendra Singh Lilhore.

(cherry picked from commit c2e2e13455)
This commit is contained in:
Xiaoyu Yao 2016-01-11 16:59:46 -08:00
parent c4aed35200
commit 521f60c094
2 changed files with 12 additions and 2 deletions

View File

@ -1698,6 +1698,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9639. Inconsistent Logging in BootstrapStandby. (Xiaobing Zhou via HDFS-9639. Inconsistent Logging in BootstrapStandby. (Xiaobing Zhou via
Arpit Agarwal) 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 Release 2.7.3 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -19,6 +19,7 @@
package org.apache.hadoop.tools; package org.apache.hadoop.tools;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.util.Random; import java.util.Random;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -270,8 +271,14 @@ public class DistCp extends Configured implements Tool {
*/ */
private void setupSSLConfig(Job job) throws IOException { private void setupSSLConfig(Job job) throws IOException {
Configuration configuration = job.getConfiguration(); Configuration configuration = job.getConfiguration();
Path sslConfigPath = new Path(configuration. URL sslFileUrl = configuration.getResource(inputOptions
getResource(inputOptions.getSslConfigurationFile()).toString()); .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); addSSLFilesToDistCache(job, sslConfigPath);
configuration.set(DistCpConstants.CONF_LABEL_SSL_CONF, sslConfigPath.getName()); configuration.set(DistCpConstants.CONF_LABEL_SSL_CONF, sslConfigPath.getName());