Shutdown Now to prevent NPE when task executed after app closed
This commit is contained in:
@@ -172,6 +172,12 @@ public class DefaultGameRepository implements GameRepository {
|
||||
if (files != null)
|
||||
for (File dir : files)
|
||||
if (dir.isDirectory()) {
|
||||
if (Thread.interrupted()) {
|
||||
this.versions = new HashMap<>();
|
||||
loaded = false;
|
||||
return;
|
||||
}
|
||||
|
||||
String id = dir.getName();
|
||||
File json = new File(dir, id + ".json");
|
||||
|
||||
|
||||
@@ -119,12 +119,12 @@ public final class Schedulers {
|
||||
Logging.LOG.info("Shutting down executor services.");
|
||||
|
||||
if (CACHED_EXECUTOR != null)
|
||||
CACHED_EXECUTOR.shutdown();
|
||||
CACHED_EXECUTOR.shutdownNow();
|
||||
|
||||
if (IO_EXECUTOR != null)
|
||||
IO_EXECUTOR.shutdown();
|
||||
IO_EXECUTOR.shutdownNow();
|
||||
|
||||
if (SINGLE_EXECUTOR != null)
|
||||
SINGLE_EXECUTOR.shutdown();
|
||||
SINGLE_EXECUTOR.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,10 @@ public final class TaskExecutor {
|
||||
|
||||
while (!workerQueue.isEmpty()) {
|
||||
Future<?> future = workerQueue.poll();
|
||||
if (future != null)
|
||||
if (future != null) {
|
||||
future.cancel(true);
|
||||
System.out.println("Canceled " + future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user