Make sure WorldHopperPlugin's executor is active on startup

We can't submit tasks to shutdown Executors. These need to be recreated
on startup
This commit is contained in:
Henry Zhang
2019-02-07 23:27:24 -08:00
parent 1ef57e3dd5
commit 13c2e2eb41

View File

@@ -131,7 +131,7 @@ public class WorldHopperPlugin extends Plugin
@Inject @Inject
private WorldHopperConfig config; private WorldHopperConfig config;
private final ScheduledExecutorService hopperExecutorService = new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()); private ScheduledExecutorService hopperExecutorService;
private NavigationButton navButton; private NavigationButton navButton;
private WorldSwitcherPanel panel; private WorldSwitcherPanel panel;
@@ -201,6 +201,8 @@ public class WorldHopperPlugin extends Plugin
} }
worldResultFuture = executorService.scheduleAtFixedRate(this::tick, 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES); worldResultFuture = executorService.scheduleAtFixedRate(this::tick, 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES);
hopperExecutorService = new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor());
pingFuture = hopperExecutorService.scheduleAtFixedRate(this::pingWorlds, WORLD_PING_TIMER, WORLD_PING_TIMER, TimeUnit.MINUTES); pingFuture = hopperExecutorService.scheduleAtFixedRate(this::pingWorlds, WORLD_PING_TIMER, WORLD_PING_TIMER, TimeUnit.MINUTES);
} }
@@ -221,6 +223,7 @@ public class WorldHopperPlugin extends Plugin
clientToolbar.removeNavigation(navButton); clientToolbar.removeNavigation(navButton);
hopperExecutorService.shutdown(); hopperExecutorService.shutdown();
hopperExecutorService = null;
} }
@Subscribe @Subscribe