felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1776232 - in /felix/trunk/configadmin-1.8.x/src: main/java/org/apache/felix/cm/impl/ConfigurationManager.java test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
Date Wed, 28 Dec 2016 07:04:42 GMT
Author: cziegeler
Date: Wed Dec 28 07:04:42 2016
New Revision: 1776232

URL: http://svn.apache.org/viewvc?rev=1776232&view=rev
Log:
FELIX-5435 : Service does not get loaded with updated properties that have been modified on
file system after felix framework restart. Apply patch from Alin Brici

Modified:
    felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
    felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java

Modified: felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1776232&r1=1776231&r2=1776232&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
(original)
+++ felix/trunk/configadmin-1.8.x/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Wed Dec 28 07:04:42 2016
@@ -683,14 +683,16 @@ public class ConfigurationManager implem
                 }
 
                 // ensure the service.pid and returned a cached config if available
-                ConfigurationImpl cfg = null;
-                if (! (pmList[i].isNotCachablePersistenceManager())) 
-                {
+                ConfigurationImpl cfg;
+                if (!(pmList[i].isNotCachablePersistenceManager())) {
                     cfg = getCachedConfiguration( pid );
-                }
-                if ( cfg == null )
-                {
-                    cfg = new ConfigurationImpl( this, pmList[i], config );
+                    if (cfg == null) {
+                        cfg = new ConfigurationImpl(this, pmList[i], config);
+                        // add the to configurations cache if it wasn't in the cache
+                        cacheConfiguration(cfg);
+                    }
+                } else {
+                    cfg = new ConfigurationImpl(this, pmList[i], config);
                 }
 
                 // FELIX-611: Ignore configuration objects without props

Modified: felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java?rev=1776232&r1=1776231&r2=1776232&view=diff
==============================================================================
--- felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
(original)
+++ felix/trunk/configadmin-1.8.x/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
Wed Dec 28 07:04:42 2016
@@ -95,12 +95,6 @@ public class ConfigurationManagerTest ex
         assertEquals(1, conf.length);
         assertEquals(2, conf[0].getProperties(true).size());
         
-        Field configurations = configMgr.getClass().getDeclaredField( "configurations" );
-        configurations.setAccessible( true );
-        HashMap<String, ConfigurationImpl> configurationsMap = new HashMap<String,
ConfigurationImpl>();
-        configurationsMap.put(pid, conf[0]);
-        configurations.set(configMgr, configurationsMap);
-        
         dictionary = new Hashtable();
         dictionary.put( "property1", "value2" );
         pid = "testDefaultPersistenceManager";
@@ -110,6 +104,9 @@ public class ConfigurationManagerTest ex
         conf = configMgr.listConfigurations(new ConfigurationAdminImpl(configMgr, null),
null);
         assertEquals(1, conf.length);
         assertEquals(2, conf[0].getProperties(true).size());
+
+        // verify that the property in the configurations cache was used
+        assertEquals("value1", conf[0].getProperties(true).get("property1"));
     }    
     
     public void test_listConfigurations_notcached() throws Exception
@@ -135,20 +132,18 @@ public class ConfigurationManagerTest ex
         assertEquals(1, conf.length);
         assertEquals(2, conf[0].getProperties(true).size());
         
-        Field configurations = configMgr.getClass().getDeclaredField( "configurations" );
-        configurations.setAccessible( true );
-        HashMap<String, ConfigurationImpl> configurationsMap = new HashMap<String,
ConfigurationImpl>();
-        configurationsMap.put(pid, conf[0]);
-        configurations.set(configMgr, configurationsMap);
-        
         dictionary = new Hashtable();
+        dictionary.put("property1", "valueNotCached");
         pid = "testDefaultPersistenceManager";
         dictionary.put( Constants.SERVICE_PID, pid );
         pm.store( pid, dictionary );
  
         conf = configMgr.listConfigurations(new ConfigurationAdminImpl(configMgr, null),
null);
         assertEquals(1, conf.length);
-        assertEquals(1, conf[0].getProperties(true).size());
+        assertEquals(2, conf[0].getProperties(true).size());
+
+        // verify that the value returned was not the one from the cache
+        assertEquals("valueNotCached", conf[0].getProperties(true).get("property1"));
     }
 
     public void testLogNoLogService()



Mime
View raw message