FELIX-881 provide getter for the service reference preventing
NullPointerException if the service has already been unregistered
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@734634 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
index acedda7..35bbdfc 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
@@ -550,6 +550,13 @@
}
+ private ServiceReference getServiceReference()
+ {
+ ServiceRegistration reg = configurationAdminRegistration;
+ return ( reg != null ) ? reg.getReference() : null;
+ }
+
+
private void configure( ServiceReference sr, ManagedService service )
{
String pid = ( String ) sr.getProperty( Constants.SERVICE_PID );
@@ -774,7 +781,7 @@
Object log = logTracker.getService();
if ( log != null )
{
- ( ( LogService ) log ).log( configurationAdminRegistration.getReference(), level, message, t );
+ ( ( LogService ) log ).log( getServiceReference(), level, message, t );
return;
}
@@ -1356,8 +1363,7 @@
return;
}
- ConfigurationEvent event = new ConfigurationEvent( configurationAdminRegistration.getReference(), type,
- factoryPid, pid );
+ ConfigurationEvent event = new ConfigurationEvent( getServiceReference(), type, factoryPid, pid );
for ( int i = 0; i < srs.length; i++ )
{