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.
@@ -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;
}
@@ -825,7 +833,14 @@ public abstract class RegionConfigurationSupport
}
private ConfigurationAdmin getConfigAdmin(BundleContext bundleContext)
+ {
+ try
{
return bundleContext.getService(caReference);
}
+ catch (IllegalStateException e)
+ {
+ return null;
+ }
+ }
}
