From issues-return-39131-archive-asf-public=cust-asf.ponee.io@karaf.apache.org Thu Mar 15 18:29:06 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8D560180654 for ; Thu, 15 Mar 2018 18:29:05 +0100 (CET) Received: (qmail 72354 invoked by uid 500); 15 Mar 2018 17:29:04 -0000 Mailing-List: contact issues-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list issues@karaf.apache.org Received: (qmail 72343 invoked by uid 99); 15 Mar 2018 17:29:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Mar 2018 17:29:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 25F55C05B3 for ; Thu, 15 Mar 2018 17:29:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 6QxZ5vlVtKMw for ; Thu, 15 Mar 2018 17:29:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 5E8545F477 for ; Thu, 15 Mar 2018 17:29:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D7AA6E022D for ; Thu, 15 Mar 2018 17:29:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 98BC521498 for ; Thu, 15 Mar 2018 17:29:00 +0000 (UTC) Date: Thu, 15 Mar 2018 17:29:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@karaf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (KARAF-5667) Installing the audit-log feature never ends MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/KARAF-5667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16400768#comment-16400768 ] ASF GitHub Bot commented on KARAF-5667: --------------------------------------- gnodet closed pull request #470: [KARAF-5667] Installing the audit-log feature never ends URL: https://github.com/apache/karaf/pull/470 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java index 5ef8870f57..8ac3e3bcb6 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java @@ -152,6 +152,7 @@ protected void doStart() throws Exception { bundleContext.getBundle(), bundleContext, systemBundleContext, + getTrackedServiceRef(ConfigurationAdmin.class).getBundle(), configInstaller, dg); register(RegionDigraphPersistence.class, () -> installSupport.saveDigraph()); @@ -326,6 +327,7 @@ protected void doStop() { if (installSupport != null) { installSupport.unregister(); installSupport.saveDigraph(); + installSupport = null; } } diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupport.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupport.java index fb31a7a462..9dc06a4852 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupport.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupport.java @@ -85,6 +85,7 @@ void replaceDigraph(Map>>> policies, class FrameworkInfo { public Bundle ourBundle; public Bundle systemBundle; + public Bundle cmBundle; public int initialBundleStartLevel; public int currentStartLevel; public Map bundles = new HashMap<>(); diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupportImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupportImpl.java index 24c2fbfcad..5b0c7e67df 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupportImpl.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/BundleInstallSupportImpl.java @@ -68,6 +68,7 @@ private final RegionDigraph digraph; private final Bundle ourBundle; + private final Bundle cmBundle; private final BundleContext ourBundleContext; private final FeatureConfigInstaller configInstaller; @@ -85,11 +86,13 @@ public BundleInstallSupportImpl(Bundle ourBundle, BundleContext ourBundleContext, BundleContext systemBundleContext, + Bundle cmBundle, FeatureConfigInstaller configInstaller, RegionDigraph digraph) { this.ourBundle = ourBundle; this.ourBundleContext = ourBundleContext; this.systemBundleContext = systemBundleContext; + this.cmBundle = cmBundle; this.configInstaller = configInstaller; this.digraph = digraph; if (systemBundleContext != null) { @@ -102,6 +105,7 @@ public BundleInstallSupportImpl(Bundle ourBundle, public void unregister() { if (hookRegistration != null) { hookRegistration.unregister(); + hookRegistration = null; } } @@ -315,6 +319,7 @@ public FrameworkInfo getInfo() { for (Bundle bundle : systemBundleContext.getBundles()) { info.bundles.put(bundle.getBundleId(), bundle); } + info.cmBundle = cmBundle; info.systemBundle = info.bundles.get(0L); return info; } diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java index dab5f60bda..14086e734c 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java @@ -79,6 +79,7 @@ import org.osgi.resource.Wire; import org.osgi.service.repository.Repository; import org.osgi.service.resolver.Resolver; +import org.osgi.util.tracker.ServiceTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -176,6 +177,8 @@ public PartialDeploymentException(Set missing) { /** A {@link Bundle} providing {@link FeaturesService} */ public Bundle serviceBundle; + /** A {@link Bundle} providing {@link org.osgi.service.cm.ConfigurationAdmin} service */ + public Bundle configadminBundle; /** {@link org.osgi.framework.startlevel.FrameworkStartLevel#getInitialBundleStartLevel()} */ public int initialBundleStartLevel; /** {@link org.osgi.framework.startlevel.FrameworkStartLevel#getStartLevel()} */ @@ -662,6 +665,7 @@ public void deploy(DeploymentState dstate, DeploymentRequest request) throws Exc // #10: send events // Bundle serviceBundle = dstate.serviceBundle; + Bundle configadminBundle = dstate.configadminBundle; // // Handle updates on the FeaturesService bundle // @@ -727,6 +731,7 @@ public void deploy(DeploymentState dstate, DeploymentRequest request) throws Exc if (!noRefresh) { Set toRefreshToStopEarly = new HashSet<>(toRefresh.keySet()); toRefreshToStopEarly.remove(dstate.serviceBundle); + toRefreshToStopEarly.remove(dstate.configadminBundle); toStop.addAll(toRefreshToStopEarly); toStart.addAll(toRefreshToStopEarly); } diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java index c6626a326f..ce36d0d5fe 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java @@ -983,6 +983,7 @@ private void doProvisionInThread(final Map> requirements, dstate.state = state; FrameworkInfo info = installSupport.getInfo(); dstate.serviceBundle = info.ourBundle; + dstate.configadminBundle = info.cmBundle; dstate.initialBundleStartLevel = info.initialBundleStartLevel; dstate.currentStartLevel = info.currentStartLevel; dstate.bundles = info.bundles; @@ -1030,6 +1031,10 @@ private void doProvision(Map> requirements, / } else { throw new Exception("Deployment aborted due to loop in missing prerequisites: " + e.getMissing()); } + } catch (Throwable t) { + // Print stack trace to stdout, there may be no log anymore + t.printStackTrace(); + throw t; } } } diff --git a/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java b/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java index c2c7204eba..d562ba1d57 100644 --- a/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java +++ b/util/src/main/java/org/apache/karaf/util/tracker/BaseActivator.java @@ -37,11 +37,7 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceRegistration; +import org.osgi.framework.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -338,6 +334,14 @@ protected void trackService(String className, String filter) throws InvalidSynta return clazz.cast(tracker.getService()); } + protected ServiceReference getTrackedServiceRef(Class clazz) { + SingleServiceTracker tracker = trackers.get(clazz.getName()); + if (tracker == null) { + throw new IllegalStateException("Service not tracked for class " + clazz); + } + return tracker.getServiceReference(); + } + /** * Called in {@link #doStart()}. * diff --git a/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java b/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java index 0c52575ec8..b4393512b7 100644 --- a/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java +++ b/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java @@ -37,7 +37,7 @@ private final BundleContext ctx; private final String className; private final AtomicReference service = new AtomicReference<>(); - private final AtomicReference ref = new AtomicReference<>(); + private final AtomicReference> ref = new AtomicReference<>(); private final AtomicBoolean open = new AtomicBoolean(false); private final BiConsumer serviceListener; private final String filterString; @@ -88,7 +88,8 @@ public void open() { public void serviceChanged(ServiceEvent event) { if (open.get()) { if (event.getType() == ServiceEvent.UNREGISTERING) { - ServiceReference deadRef = event.getServiceReference(); + @SuppressWarnings("unchecked") + ServiceReference deadRef = (ServiceReference) event.getServiceReference(); if (deadRef.equals(ref.get())) { findMatchingReference(deadRef); } @@ -98,22 +99,23 @@ public void serviceChanged(ServiceEvent event) { } } - private void findMatchingReference(ServiceReference original) { + private void findMatchingReference(ServiceReference original) { try { boolean clear = true; - ServiceReference[] refs = ctx.getServiceReferences(className, filterString); + ServiceReference[] refs = ctx.getServiceReferences(className, filterString); if (refs != null && refs.length > 0) { if (refs.length > 1) { Arrays.sort(refs); } @SuppressWarnings("unchecked") - T service = (T) ctx.getService(refs[0]); + ServiceReference r = (ServiceReference) refs[0]; + T service = ctx.getService(r); if (service != null) { clear = false; // We do the unget out of the lock so we don't exit this class while holding a lock. - if (!update(original, refs[0], service)) { - ctx.ungetService(refs[0]); + if (!update(original, r, service)) { + ctx.ungetService(r); } } } else if (original == null) { @@ -128,7 +130,7 @@ private void findMatchingReference(ServiceReference original) { } } - private boolean update(ServiceReference deadRef, ServiceReference newRef, T service) { + private boolean update(ServiceReference deadRef, ServiceReference newRef, T service) { boolean result = false; T prev = null; ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org > Installing the audit-log feature never ends > ------------------------------------------- > > Key: KARAF-5667 > URL: https://issues.apache.org/jira/browse/KARAF-5667 > Project: Karaf > Issue Type: Bug > Reporter: Guillaume Nodet > Assignee: Guillaume Nodet > Priority: Critical > Fix For: 4.2.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)