From 0eb07609b66bec92d2f5479a1939f64ca3c8bdc0 Mon Sep 17 00:00:00 2001 From: tedyu Date: Tue, 18 Nov 2014 09:18:25 -0800 Subject: [PATCH] HBASE-12337 Import tool fails with NullPointerException if clusterIds is not initialized --- .../java/org/apache/hadoop/hbase/mapreduce/Import.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java index 1033dace35b..15540c6671c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java @@ -231,18 +231,26 @@ public class Import extends Configured implements Tool { } // TODO: This is kind of ugly doing setup of ZKW just to read the clusterid. ZooKeeperWatcher zkw = null; + Exception ex = null; try { zkw = new ZooKeeperWatcher(conf, context.getTaskAttemptID().toString(), null); clusterIds = Collections.singletonList(ZKClusterId.getUUIDForCluster(zkw)); } catch (ZooKeeperConnectionException e) { + ex = e; LOG.error("Problem connecting to ZooKeper during task setup", e); } catch (KeeperException e) { + ex = e; LOG.error("Problem reading ZooKeeper data during task setup", e); } catch (IOException e) { + ex = e; LOG.error("Problem setting up task", e); } finally { if (zkw != null) zkw.close(); } + if (clusterIds == null) { + // exit early if setup fails + throw new RuntimeException(ex); + } } }