From c58e80fbe6db6426e652ec363149b92f9e33fbb0 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 1 Nov 2019 21:40:23 -0700 Subject: [PATCH] HBASE-23244 NPEs running Canary (#784) Signed-off-by: Viraj Jasani --- .../java/org/apache/hadoop/hbase/tool/CanaryTool.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java index 6302df563c6..a967dab8175 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java @@ -492,7 +492,8 @@ public class CanaryTool implements Tool, Canary { sink.publishReadTiming(serverName, region, column, stopWatch.getTime()); } catch (Exception e) { sink.publishReadFailure(serverName, region, column, e); - sink.updateReadFailures(region.getRegionNameAsString(), serverName.getHostname()); + sink.updateReadFailures(region == null? "NULL": region.getRegionNameAsString(), + serverName == null? "NULL": serverName.getHostname()); } finally { if (rs != null) { rs.close(); @@ -1579,6 +1580,10 @@ public class CanaryTool implements Tool, Canary { try (RegionLocator regionLocator = admin.getConnection().getRegionLocator(tableDesc.getTableName())) { for (HRegionLocation location: regionLocator.getAllRegionLocations()) { + if (location == null) { + LOG.warn("Null location"); + continue; + } ServerName rs = location.getServerName(); RegionInfo region = location.getRegion(); tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink)sink, @@ -1795,6 +1800,10 @@ public class CanaryTool implements Tool, Canary { try (RegionLocator regionLocator = this.admin.getConnection().getRegionLocator(tableDesc.getTableName())) { for (HRegionLocation location : regionLocator.getAllRegionLocations()) { + if (location == null) { + LOG.warn("Null location"); + continue; + } ServerName rs = location.getServerName(); String rsName = rs.getHostname(); RegionInfo r = location.getRegion();