This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.osgi-mock-1.6.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit 29e4a32d65769ac60434395828612b7708e3da97 Author: Stefan Seifert <[email protected]> AuthorDate: Fri Oct 2 23:44:31 2015 +0000 SLING-5088 properly shutdown executor service in MockEventAdmin git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1706506 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/sling/testing/mock/osgi/MockEventAdmin.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java index 68d55ca..55628da 100644 --- a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java +++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java @@ -25,12 +25,15 @@ import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.ReferencePolicy; import org.apache.felix.scr.annotations.Service; import org.apache.sling.commons.osgi.ServiceUtil; +import org.osgi.service.component.ComponentContext; import org.osgi.service.event.Event; import org.osgi.service.event.EventAdmin; import org.osgi.service.event.EventConstants; @@ -50,9 +53,19 @@ public final class MockEventAdmin implements EventAdmin { cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC) private final Map<Object, EventHandlerItem> eventHandlers = new TreeMap<Object, EventHandlerItem>(); - private ExecutorService asyncHandler = Executors.newCachedThreadPool(); + private ExecutorService asyncHandler; private static final Logger log = LoggerFactory.getLogger(MockEventAdmin.class); + + @Activate + protected void activate(ComponentContext componentContext) { + asyncHandler = Executors.newCachedThreadPool(); + } + + @Deactivate + protected void deactivate(ComponentContext componentContext) { + asyncHandler.shutdownNow(); + } @Override public void postEvent(final Event event) { -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
