FELIX-2766 Don't throw FileNotFoundException when calling
update() (no-arg signature) on newly created Factory configuration.
Just assume an empty configuration. Also provide ManagedService[Factory]
with empty dictionary if the configuration has no properties (yet) on
update which is the case when calling no-arg update() on newly
created configurations.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1067270 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
index d7060fb..2ff0b4d 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
@@ -257,17 +257,20 @@
         if ( localPersistenceManager != null )
         {
             // read configuration from persistence (again)
-            Dictionary properties = localPersistenceManager.load( getPid() );
-
-            // ensure serviceReference pid
-            String servicePid = ( String ) properties.get( Constants.SERVICE_PID );
-            if ( servicePid != null && !getPid().equals( servicePid ) )
+            if ( localPersistenceManager.exists( getPid() ) )
             {
-                throw new IOException( "PID of configuration file does match requested PID; expected " + getPid() + ", got "
-                    + servicePid );
-            }
+                Dictionary properties = localPersistenceManager.load( getPid() );
 
-            configureFromPersistence( properties );
+                // ensure serviceReference pid
+                String servicePid = ( String ) properties.get( Constants.SERVICE_PID );
+                if ( servicePid != null && !getPid().equals( servicePid ) )
+                {
+                    throw new IOException( "PID of configuration file does match requested PID; expected " + getPid()
+                        + ", got " + servicePid );
+                }
+
+                configureFromPersistence( properties );
+            }
 
             // update the service but do not fire an CM_UPDATED event
             getConfigurationManager().updated( this, false );
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 fa8cb9b..5787eaa 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
@@ -1417,7 +1417,13 @@
             this.config = config;
             synchronized ( config )
             {
-                this.properties = config.getProperties( true );
+                Dictionary props = config.getProperties( true );
+                if ( props == null )
+                {
+                    props = new Hashtable();
+                }
+
+                this.properties = props;
                 this.lastModificationTime = config.getLastModificationTime();
             }
         }
@@ -1575,7 +1581,7 @@
                             {
                                 final ManagedServiceFactory srv = ( ManagedServiceFactory ) bundleContext
                                     .getService( ref );
-                                if ( srv != null && properties != null )
+                                if ( srv != null )
                                 {
                                     Dictionary props = new CaseInsensitiveDictionary( properties );
                                     callPlugins( props, config.getFactoryPid(), ref, config );