Amend HBASE-18830 TestCanaryTool does not check Canary monitor's error code
Adjust exception control flow to fix findbugs warning NP_NULL_ON_SOME_PATH_EXCEPTION, Possible null pointer dereference of regionSink in org.apache.hadoop.hbase.tool.Canary$RegionMonitor.run() on exception path
This commit is contained in:
parent
6d0eb0eef0
commit
ede916af5a
|
@ -1028,19 +1028,14 @@ public final class Canary implements Tool {
|
||||||
if (this.initAdmin()) {
|
if (this.initAdmin()) {
|
||||||
try {
|
try {
|
||||||
List<Future<Void>> taskFutures = new LinkedList<>();
|
List<Future<Void>> taskFutures = new LinkedList<>();
|
||||||
RegionStdOutSink regionSink = null;
|
RegionStdOutSink regionSink = this.getSink();
|
||||||
try {
|
|
||||||
regionSink = this.getSink();
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
LOG.error("Run RegionMonitor failed!", e);
|
|
||||||
this.errorCode = ERROR_EXIT_CODE;
|
|
||||||
}
|
|
||||||
if (this.targets != null && this.targets.length > 0) {
|
if (this.targets != null && this.targets.length > 0) {
|
||||||
String[] tables = generateMonitorTables(this.targets);
|
String[] tables = generateMonitorTables(this.targets);
|
||||||
// Check to see that each table name passed in the -readTableTimeouts argument is also passed as a monitor target.
|
// Check to see that each table name passed in the -readTableTimeouts argument is also passed as a monitor target.
|
||||||
if (! new HashSet<>(Arrays.asList(tables)).containsAll(this.configuredReadTableTimeouts.keySet())) {
|
if (! new HashSet<>(Arrays.asList(tables)).containsAll(this.configuredReadTableTimeouts.keySet())) {
|
||||||
LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets passed via command line.");
|
LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets passed via command line.");
|
||||||
this.errorCode = USAGE_EXIT_CODE;
|
this.errorCode = USAGE_EXIT_CODE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
for (String table : tables) {
|
for (String table : tables) {
|
||||||
|
@ -1103,6 +1098,8 @@ public final class Canary implements Tool {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Run regionMonitor failed", e);
|
LOG.error("Run regionMonitor failed", e);
|
||||||
this.errorCode = ERROR_EXIT_CODE;
|
this.errorCode = ERROR_EXIT_CODE;
|
||||||
|
} finally {
|
||||||
|
this.done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.done = true;
|
this.done = true;
|
||||||
|
|
Loading…
Reference in New Issue