HBASE-15229 Canary Tools should not call System.Exit on error (Vishal Khandelwal)

This commit is contained in:
Andrew Purtell 2016-02-10 10:19:49 -08:00
parent d53318163b
commit 2963d59ed2
1 changed files with 6 additions and 7 deletions

View File

@ -607,9 +607,9 @@ public final class Canary implements Tool {
if (this.failOnError && monitor.hasError()) { if (this.failOnError && monitor.hasError()) {
monitorThread.interrupt(); monitorThread.interrupt();
if (monitor.initialized) { if (monitor.initialized) {
System.exit(monitor.errorCode); return monitor.errorCode;
} else { } else {
System.exit(INIT_ERROR_EXIT_CODE); return INIT_ERROR_EXIT_CODE;
} }
} }
currentTimeLength = System.currentTimeMillis() - startTime; currentTimeLength = System.currentTimeMillis() - startTime;
@ -618,17 +618,16 @@ public final class Canary implements Tool {
+ ") after timeout limit:" + this.timeout + ") after timeout limit:" + this.timeout
+ " will be killed itself !!"); + " will be killed itself !!");
if (monitor.initialized) { if (monitor.initialized) {
System.exit(TIMEOUT_ERROR_EXIT_CODE); return TIMEOUT_ERROR_EXIT_CODE;
} else { } else {
System.exit(INIT_ERROR_EXIT_CODE); return INIT_ERROR_EXIT_CODE;
} }
break;
} }
} }
if (this.failOnError && monitor.finalCheckForErrors()) { if (this.failOnError && monitor.finalCheckForErrors()) {
monitorThread.interrupt(); monitorThread.interrupt();
System.exit(monitor.errorCode); return monitor.errorCode;
} }
} finally { } finally {
if (monitor != null) monitor.close(); if (monitor != null) monitor.close();
@ -641,7 +640,7 @@ public final class Canary implements Tool {
if (choreService != null) { if (choreService != null) {
choreService.shutdown(); choreService.shutdown();
} }
return(monitor.errorCode); return monitor.errorCode;
} }
private void printUsageAndExit() { private void printUsageAndExit() {