Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7249D200D35 for ; Tue, 7 Nov 2017 11:23:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 70E061609C8; Tue, 7 Nov 2017 10:23:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AAAB8160C04 for ; Tue, 7 Nov 2017 11:23:26 +0100 (CET) Received: (qmail 6305 invoked by uid 500); 7 Nov 2017 10:23:24 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 5222 invoked by uid 99); 7 Nov 2017 10:23:24 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Nov 2017 10:23:24 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 991DE87C76; Tue, 7 Nov 2017 10:23:23 +0000 (UTC) Date: Tue, 07 Nov 2017 10:24:09 +0000 To: "commits@sling.apache.org" Subject: [sling-org-apache-sling-testing-sling-mock-oak] 03/07: SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: rombert@apache.org In-Reply-To: <151005020130.10948.6918645054216733986@gitbox.apache.org> References: <151005020130.10948.6918645054216733986@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: sling-org-apache-sling-testing-sling-mock-oak X-Git-Refname: refs/tags/org.apache.sling.testing.sling-mock-oak-2.0.0 X-Git-Reftype: annotated tag X-Git-Rev: 7985024037618c3630a49748451663f743931619 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20171107102323.991DE87C76@gitbox.apache.org> archived-at: Tue, 07 Nov 2017 10:23:29 -0000 This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.sling-mock-oak-2.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock-oak.git commit 7985024037618c3630a49748451663f743931619 Author: Stefan Seifert AuthorDate: Tue Feb 23 02:06:41 2016 +0000 SLING-5547 Update sling-mock-oak to Sling API 2.11 and Oak 1.3.15 git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock-oak@1731778 13f79535-47bb-0310-9956-ffa450edef68 --- .../mock/sling/oak/OakMockSlingRepository.java | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java index cd6133a..45f7094 100644 --- a/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java +++ b/src/main/java/org/apache/sling/testing/mock/sling/oak/OakMockSlingRepository.java @@ -18,6 +18,7 @@ */ package org.apache.sling.testing.mock.sling.oak; +import java.lang.reflect.Field; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -42,6 +43,8 @@ import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.sling.jcr.api.SlingRepository; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Component @Service(SlingRepository.class) @@ -54,6 +57,8 @@ public final class OakMockSlingRepository implements SlingRepository { private ExecutorService executor; private ScheduledExecutorService scheduledExecutor; + private static final Logger log = LoggerFactory.getLogger(OakMockSlingRepository.class); + @Activate protected void activate(BundleContext bundleContext) { executor = Executors.newSingleThreadExecutor(); @@ -77,12 +82,26 @@ public final class OakMockSlingRepository implements SlingRepository { @Deactivate protected void deactivate(ComponentContext componentContext) { - // shutdown OAK JCR repository - ((JackrabbitRepository)repository).shutdown(); - // shutdown executors + // force immediate shutdown for all executors without waiting for tasks for completion - we're only in unit tests! executor.shutdownNow(); scheduledExecutor.shutdownNow(); + shutdownExecutorService(repository, "scheduledExecutor"); + + // shutdown OAK JCR repository + ((JackrabbitRepository)repository).shutdown(); + } + + private void shutdownExecutorService(Object instance, String fieldName) { + try { + Field executorField = instance.getClass().getDeclaredField(fieldName); + executorField.setAccessible(true); + ExecutorService executor = (ExecutorService)executorField.get(instance); + executor.shutdownNow(); + } + catch (Throwable ex) { + log.error("Potential Memory leak: Unable to shutdown executor service from field '" + fieldName + "' in " + instance, ex); + } } public String getDescriptor(String key) { -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" .