mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 01:27: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,15 +145,18 @@ public class Processing implements SubSystem {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
if (!nonCriticalExecutor.isTerminated()) {
|
||||
try {
|
||||
nonCriticalExecutor.awaitTermination(1, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
try {
|
||||
if (!nonCriticalExecutor.isTerminated() && !nonCriticalExecutor.awaitTermination(1, TimeUnit.SECONDS)) {
|
||||
nonCriticalExecutor.shutdownNow();
|
||||
}
|
||||
}
|
||||
if (!criticalExecutor.isTerminated()) {
|
||||
if (!criticalExecutor.isTerminated()) {
|
||||
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));
|
||||
}
|
||||
|
@ -258,9 +258,12 @@ public class WebServer implements SubSystem {
|
||||
ExecutorService service = (ExecutorService) executor;
|
||||
service.shutdown();
|
||||
try {
|
||||
service.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException timeoutExceededEx) {
|
||||
service.shutdownNow();
|
||||
if (!service.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
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