mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-29 23:09:42 +01:00
[Smell] Improper InterruptedException handling
- Fixes thread interruption if interrupted during WebServer shutdown - Fixes thread interruption if interrupted during Processing shutdown
This commit is contained in:
parent
c513e08728
commit
6b3d07dac1
@ -145,16 +145,19 @@ public class Processing implements SubSystem {
|
|||||||
errorHandler.log(L.WARN, this.getClass(), e);
|
errorHandler.log(L.WARN, this.getClass(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!nonCriticalExecutor.isTerminated()) {
|
|
||||||
try {
|
try {
|
||||||
nonCriticalExecutor.awaitTermination(1, TimeUnit.SECONDS);
|
if (!nonCriticalExecutor.isTerminated() && !nonCriticalExecutor.awaitTermination(1, TimeUnit.SECONDS)) {
|
||||||
} catch (InterruptedException e) {
|
|
||||||
nonCriticalExecutor.shutdownNow();
|
nonCriticalExecutor.shutdownNow();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!criticalExecutor.isTerminated()) {
|
if (!criticalExecutor.isTerminated()) {
|
||||||
criticalExecutor.shutdownNow();
|
criticalExecutor.shutdownNow();
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("Processing shutdown thread interrupted: " + e.getMessage());
|
||||||
|
nonCriticalExecutor.shutdownNow();
|
||||||
|
criticalExecutor.shutdownNow();
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
logger.info(locale.get().getString(PluginLang.DISABLED_PROCESSING_COMPLETE));
|
logger.info(locale.get().getString(PluginLang.DISABLED_PROCESSING_COMPLETE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,10 +258,13 @@ public class WebServer implements SubSystem {
|
|||||||
ExecutorService service = (ExecutorService) executor;
|
ExecutorService service = (ExecutorService) executor;
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
try {
|
try {
|
||||||
service.awaitTermination(5, TimeUnit.SECONDS);
|
if (!service.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||||
} catch (InterruptedException timeoutExceededEx) {
|
|
||||||
service.shutdownNow();
|
service.shutdownNow();
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("WebServer ExecutorService shutdown thread interrupted on disable: " + e.getMessage());
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user