From 9aac957b9c0e9f6c644df5cb529d5cd1a118dff8 Mon Sep 17 00:00:00 2001 From: Jarek Jarcec Cecho Date: Thu, 17 Jul 2014 07:52:39 -0700 Subject: [PATCH] SQOOP-1370: AccumuloUtils can throw NPE when zookeeper or accumulo home is null (Mike Drob via Jarek Jarcec Cecho) --- .../apache/sqoop/accumulo/AccumuloUtil.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/sqoop/accumulo/AccumuloUtil.java b/src/java/org/apache/sqoop/accumulo/AccumuloUtil.java index 1cbb8594..06888c5d 100644 --- a/src/java/org/apache/sqoop/accumulo/AccumuloUtil.java +++ b/src/java/org/apache/sqoop/accumulo/AccumuloUtil.java @@ -105,13 +105,22 @@ public static void addJars(Job job, SqoopOptions options) throws IOException { .addAll(conf.getStringCollection( ConfigurationConstants.MAPRED_DISTCACHE_CONF_PARAM)); - String dir = accumuloHome + File.separator + "lib"; - LOG.info("Adding jar files under " + dir + " to distributed cache"); - addDirToCache(new File(dir), fs, localUrls, false); + if (null == accumuloHome) { + throw new IllegalArgumentException("ACCUMULO_HOME is not set."); + } else { + File dir = new File(accumuloHome, "lib"); + String path = dir.getPath(); + LOG.info("Adding jar files under " + path + " to distributed cache"); + addDirToCache(dir, fs, localUrls, false); + } - dir = zookeeperHome; - LOG.info("Adding jar files under " + dir + " to distributed cache"); - addDirToCache(new File(dir), fs, localUrls, false); + if (null == zookeeperHome) { + throw new IllegalArgumentException("ZOOKEEPER_HOME is not set."); + } else { + String dir = zookeeperHome; + LOG.info("Adding jar files under " + dir + " to distributed cache"); + addDirToCache(new File(dir), fs, localUrls, false); + } String tmpjars = conf .get(ConfigurationConstants.MAPRED_DISTCACHE_CONF_PARAM);