diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 8f84eb3f..7cf21276 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -389,6 +389,10 @@ public class Core { saveMuSettings() log.info("shutting down trust subscriber") trustSubscriber.stop() + log.info("shutting down trust service") + trustService.stop() + log.info("shutting down persister service") + persisterService.stop() log.info("shutting down download manager") downloadManager.shutdown() log.info("shutting down connection acceptor") @@ -411,6 +415,8 @@ public class Core { log.info("shutting down embedded router") router.shutdown(0) } + log.info("shutting down event bus"); + eventBus.shutdown() log.info("shutdown complete") } diff --git a/core/src/main/groovy/com/muwire/core/EventBus.groovy b/core/src/main/groovy/com/muwire/core/EventBus.groovy index 943da8ce..f3654fde 100644 --- a/core/src/main/groovy/com/muwire/core/EventBus.groovy +++ b/core/src/main/groovy/com/muwire/core/EventBus.groovy @@ -2,6 +2,7 @@ package com.muwire.core import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.logging.Level @@ -12,7 +13,7 @@ import groovy.util.logging.Log class EventBus { private Map handlers = new HashMap() - private final Executor executor = Executors.newSingleThreadExecutor {r -> + private final ExecutorService executor = Executors.newSingleThreadExecutor {r -> def rv = new Thread(r) rv.setDaemon(true) rv.setName("event-bus") @@ -53,4 +54,8 @@ class EventBus { log.info("Unregistering $handler for type $eventType") handlers[eventType]?.remove(handler) } + + void shutdown() { + executor.shutdownNow() + } }