HBASE-14662 Fix NPE in HFileOutputFormat2 (Heng Chen)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/81e2aba1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/81e2aba1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/81e2aba1 Branch: refs/heads/hbase-12439 Commit: 81e2aba1f9bbe592d9d9284e701af5bedad3cd56 Parents: 5363f37 Author: stack <st...@apache.org> Authored: Wed Oct 21 21:48:47 2015 -0700 Committer: stack <st...@apache.org> Committed: Wed Oct 21 21:48:47 2015 -0700 ---------------------------------------------------------------------- .../hbase/mapreduce/HFileOutputFormat2.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/81e2aba1/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java index 388c017..a183773 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java @@ -210,15 +210,16 @@ public class HFileOutputFormat2 if (conf.getBoolean(LOCALITY_SENSITIVE_CONF_KEY, DEFAULT_LOCALITY_SENSITIVE)) { HRegionLocation loc = null; String tableName = conf.get(OUTPUT_TABLE_NAME_CONF_KEY); - - try (Connection connection = ConnectionFactory.createConnection(conf); - RegionLocator locator = - connection.getRegionLocator(TableName.valueOf(tableName))) { - loc = locator.getRegionLocation(rowKey); - } catch (Throwable e) { - LOG.warn("there's something wrong when locating rowkey: " + - Bytes.toString(rowKey), e); - loc = null; + if (tableName != null) { + try (Connection connection = ConnectionFactory.createConnection(conf); + RegionLocator locator = + connection.getRegionLocator(TableName.valueOf(tableName))) { + loc = locator.getRegionLocation(rowKey); + } catch (Throwable e) { + LOG.warn("there's something wrong when locating rowkey: " + + Bytes.toString(rowKey), e); + loc = null; + } } if (null == loc) {