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 2020/04/03 16:36:04 UTC

[felix-dev] branch master updated: FELIX-6241 - Ignore IllegalStateException on ungetService

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 f0659dfa FELIX-6241 - Ignore IllegalStateException on ungetService
f0659dfa is described below

commit f0659dfa0407889fe05359c7e31dc0d405e58228
Author: Thomas Watson <tj...@us.ibm.com>
AuthorDate: Fri Apr 3 11:28:46 2020 -0500

    FELIX-6241 - Ignore IllegalStateException on ungetService
    
    Another case where the BundleContext become invalid while processing.
    These cases should be ignored and move on without errors/warnings
    because they are expected when a bundle is stopped.
---
 .../scr/impl/manager/RegionConfigurationSupport.java  | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/RegionConfigurationSupport.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/RegionConfigurationSupport.java
index a338f15..f48e2e7 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/RegionConfigurationSupport.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/RegionConfigurationSupport.java
@@ -163,6 +163,10 @@ public abstract class RegionConfigurationSupport
             final List<String> confPids = holder.getComponentMetadata().getConfigurationPid();
 
             final ConfigurationAdmin ca = getConfigAdmin( bundleContext );
+            if (ca == null)
+            {
+                return false; // bundle was stopped concurrently
+            }
             try
             {
                 for ( final String confPid : confPids )
@@ -501,6 +505,10 @@ public abstract class RegionConfigurationSupport
         try
         {
             final ConfigurationAdmin ca = getConfigAdmin( bundleContext );
+            if (ca == null)
+            {
+                return null;
+            }
             try
             {
                 Configuration[] configs = ca.listConfigurations( filter( pid.getRawPid() ) );
@@ -539,7 +547,7 @@ public abstract class RegionConfigurationSupport
         catch ( IllegalStateException ise )
         {
             // If the bundle has been stopped concurrently
-            logger.log( LogService.LOG_WARNING, "Bundle in unexpected state", ise );
+            logger.log(LogService.LOG_DEBUG, "Bundle in unexpected state", ise);
         }
         return null;
     }
@@ -826,6 +834,13 @@ public abstract class RegionConfigurationSupport
 
     private ConfigurationAdmin getConfigAdmin(BundleContext bundleContext)
     {
-        return bundleContext.getService( caReference );
+        try
+        {
+            return bundleContext.getService(caReference);
+        }
+        catch (IllegalStateException e)
+        {
+            return null;
+        }
     }
 }