You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by tj...@apache.org on 2022/11/11 15:36:47 UTC

[felix-dev] branch master updated: FELIX-6581 - use system context to clean up logger domains

This is an automated email from the ASF dual-hosted git repository.

tjwatson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 619d36714a FELIX-6581 - use system context to clean up logger domains
619d36714a is described below

commit 619d36714a9a1258a4c1d56b8b0d581fa7860903
Author: Thomas Watson <tj...@us.ibm.com>
AuthorDate: Fri Nov 11 09:32:01 2022 -0600

    FELIX-6581 - use system context to clean up logger domains
    
    Always using the system context to clean up the logger domians.
    It is more simple to always use the system context for this
    purpose instead of conditionally use it according to the
    ds.global.extender configuration.  There is no harm to using
    always using the system context here because we only use it to
    listen for stopped bundles to clean up used domains.
---
 .../main/java/org/apache/felix/scr/impl/logger/LogManager.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scr/src/main/java/org/apache/felix/scr/impl/logger/LogManager.java b/scr/src/main/java/org/apache/felix/scr/impl/logger/LogManager.java
index dd3cae05a1..0a5fecf6a7 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/logger/LogManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/logger/LogManager.java
@@ -51,6 +51,7 @@ class LogManager extends ServiceTracker<Object, Object> implements BundleListene
     private static final String LOGGER_FACTORY_CLASS_NAME = "org.osgi.service.log.LoggerFactory";
 
     final BundleContext scrContext;
+    final BundleContext systemContext;
     final AtomicBoolean closed = new AtomicBoolean(false);
 
     /*
@@ -150,6 +151,7 @@ class LogManager extends ServiceTracker<Object, Object> implements BundleListene
     {
         super(context, LOGGER_FACTORY_CLASS_NAME, null);
         this.scrContext = context;
+        this.systemContext = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext();
         this.config = config;
     }
     
@@ -174,7 +176,10 @@ class LogManager extends ServiceTracker<Object, Object> implements BundleListene
     {
         if (!config.isLogExtensionEnabled()) 
         {
-            scrContext.addBundleListener(this);
+            // Use system context to do cleanup of domains.
+            // This ensures we always can cleanup even when the SCR context
+            // cannot see the bundle.
+            systemContext.addBundleListener(this);
         }
         this.open();
     }
@@ -305,7 +310,7 @@ class LogManager extends ServiceTracker<Object, Object> implements BundleListene
         {
             lock.close();
             super.close();
-            this.context.removeBundleListener(this);
+            this.systemContext.removeBundleListener(this);
         }
     }