FELIX-1477 Apply slightly modified (formatting) patch by Andy Wilkinson
(thanks alot !) to make the implementation more thread-safe

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@804344 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 f129642..82e5b16 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
@@ -560,6 +560,7 @@
         if ( persistenceManagers == null || currentPmtCount > pmtCount )
         {
 
+            List pmList = new ArrayList();
             PersistenceManager[] pm;
 
             ServiceReference[] refs = persistenceManagerTracker.getServiceReferences();
@@ -577,16 +578,21 @@
                 }
 
                 // create the service array from the sorted set of referenecs
-                pm = new PersistenceManager[pms.size()];
                 int pmIndex = 0;
-                for ( Iterator pi = pms.iterator(); pi.hasNext(); pmIndex++)
+                for ( Iterator pi = pms.iterator(); pi.hasNext(); pmIndex++ )
                 {
                     ServiceReference ref = ( ServiceReference ) pi.next();
-                    pm[pmIndex] = ( PersistenceManager ) persistenceManagerTracker.getService( ref );
+                    Object service = persistenceManagerTracker.getService( ref );
+                    if ( service != null )
+                    {
+                        pmList.add( service );
+                    }
                 }
+
+                pm = ( PersistenceManager[] ) pmList.toArray( new PersistenceManager[pmList.size()] );
             }
 
-            pmtCount = currentPmtCount;
+            pmtCount = pm.length;
             persistenceManagers = pm;
         }