FELIX-2847 Prevent NPE if service already unregistered

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1071990 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 5787eaa..b94e322 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
@@ -1006,18 +1006,28 @@
     static String toString( ServiceReference ref )
     {
         String[] ocs = ( String[] ) ref.getProperty( "objectClass" );
-        String oc = "[";
+        StringBuffer buf = new StringBuffer("[");
         for ( int i = 0; i < ocs.length; i++ )
         {
-            oc += ocs[i];
+            buf.append(ocs[i]);
             if ( i < ocs.length - 1 )
-                oc += ", ";
+                buf.append(", ");
         }
 
-        oc += ", id=" + ref.getProperty( Constants.SERVICE_ID );
-        oc += ", bundle=" + ref.getBundle().getBundleId();
-        oc += "]";
-        return oc;
+        buf.append( ", id=" ).append( ref.getProperty( Constants.SERVICE_ID ) );
+
+        Bundle provider = ref.getBundle();
+        if ( provider != null )
+        {
+            buf.append( ", bundle=" ).append( provider.getBundleId() );
+        }
+        else
+        {
+            buf.append( ", unregistered" );
+        }
+
+        buf.append( "]" );
+        return buf.toString();
     }