src/main/java/org/cobbzilla/util/daemon/ZillaRuntime.javaVoir le fichier
@@ -79,7 +79,7 @@ public class ZillaRuntime {
public static TerminationRequestResult terminate(Thread thread, long timeout, Function<Thread, Boolean> onlyIf, boolean verbose) {
if (thread == null || !thread.isAlive()) return TerminationRequestResult.dead;
if (onlyIf != null && !onlyIf.apply(thread)) {
if (log.isWarnEnabled()) log.warn("terminate: thread is alive but onlyIf function returned false, not interrupting: " + thread + (verbose ? " with stack " + stacktrace(thread) + "\nfrom: " + stacktrace() : ""));
if (log.isWarnEnabled()) log.warn("terminate: thread is alive but onlyIf function returned false, not interrupting: " + thread + terminateVerbose(thread, verbose));
return TerminationRequestResult.alive;
}
thread.interrupt();
@@ -89,19 +89,27 @@ public class ZillaRuntime {
}
if (thread.isAlive()) {
if (onlyIf != null && onlyIf.apply(thread)) {
if (log.isWarnEnabled()) log.warn("terminate: thread did not respond to interrupt, killing: " + thread + (verbose ? " with stack " + stacktrace(thread) + "\nfrom: " + stacktrace() : ""));
if (log.isWarnEnabled()) log.warn("terminate: thread did not respond to interrupt, killing: " + thread + terminateVerbose(thread, verbose));
thread.stop();
return TerminationRequestResult.terminated;
} else {
if (log.isWarnEnabled()) log.warn("terminate: thread did not respond to interrupt, but onlyIf function returned false, not killing: " + thread + (verbose ? " with stack " + stacktrace(thread) + "\nfrom: " + stacktrace() : ""));
if (log.isWarnEnabled()) log.warn("terminate: thread did not respond to interrupt, but onlyIf function returned false, not killing: " + thread + terminateVerbose(thread, verbose));
if (log.isWarnEnabled()) log.warn("terminate: thread exited after interrupt: "+thread+(thread.getName().startsWith("Thread-") ? " with stack: "+stacktrace(thread) : ""));
if (log.isWarnEnabled()) log.warn("terminate: thread exited after interrupt: "+thread + terminateVerbose(thread, verbose));
return TerminationRequestResult.interrupted_dead;
}
}
public static String terminateVerbose(Thread thread, boolean verbose) {