Made processing shutdown more aggressively

Affects issues:
- #1814
This commit is contained in:
Risto Lahtela 2021-03-25 08:00:04 +02:00
parent 4f39481549
commit a0029f1df8

View File

@ -152,10 +152,13 @@ public class Processing implements SubSystem {
} }
private void shutdownNonCriticalExecutor() { private void shutdownNonCriticalExecutor() {
nonCriticalExecutor.shutdown(); nonCriticalExecutor.shutdownNow();
} }
private void shutdownCriticalExecutor() { private void shutdownCriticalExecutor() {
criticalExecutor.shutdown();
try {
if (!criticalExecutor.awaitTermination(3, TimeUnit.SECONDS)) {
List<Runnable> criticalTasks = criticalExecutor.shutdownNow(); List<Runnable> criticalTasks = criticalExecutor.shutdownNow();
logger.info(locale.get().getString(PluginLang.DISABLED_PROCESSING, criticalTasks.size())); logger.info(locale.get().getString(PluginLang.DISABLED_PROCESSING, criticalTasks.size()));
for (Runnable runnable : criticalTasks) { for (Runnable runnable : criticalTasks) {
@ -167,13 +170,17 @@ public class Processing implements SubSystem {
} }
} }
} }
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
private void ensureShutdown() { private void ensureShutdown() {
try { try {
if (!nonCriticalExecutor.isTerminated() && !nonCriticalExecutor.awaitTermination(1, TimeUnit.SECONDS)) { if (!nonCriticalExecutor.isTerminated()) {
nonCriticalExecutor.shutdownNow(); nonCriticalExecutor.shutdownNow();
} }
if (!criticalExecutor.isTerminated()) { if (!criticalExecutor.isTerminated() && !criticalExecutor.awaitTermination(1, TimeUnit.SECONDS)) {
criticalExecutor.shutdownNow(); criticalExecutor.shutdownNow();
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {