[FELIX-2698] File Install Circular Configuration Update Loop
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1040664 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
index 31e63d8..4711033 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
@@ -21,6 +21,7 @@
import org.apache.felix.cm.file.ConfigurationHandler;
import org.apache.felix.fileinstall.ArtifactInstaller;
import org.apache.felix.fileinstall.internal.Util.Logger;
+import org.apache.felix.utils.collections.DictionaryAsMap;
import org.apache.felix.utils.properties.InterpolationHelper;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -116,7 +117,9 @@
for( Enumeration e = dict.keys(); e.hasMoreElements(); )
{
String key = e.nextElement().toString();
- if( !Constants.SERVICE_PID.equals(key) && !DirectoryWatcher.FILENAME.equals(key) )
+ if( !Constants.SERVICE_PID.equals(key)
+ && !ConfigurationAdmin.SERVICE_FACTORYPID.equals(key)
+ && !DirectoryWatcher.FILENAME.equals(key) )
{
String val = dict.get( key ).toString();
props.put( key, val );
@@ -195,14 +198,27 @@
}
String pid[] = parsePid(f.getName());
- ht.put(DirectoryWatcher.FILENAME, f.getAbsolutePath());
Configuration config = getConfiguration(f.getAbsolutePath(), pid[0], pid[1]);
- if (config.getBundleLocation() != null)
+
+ Hashtable old = new Hashtable(new DictionaryAsMap(config.getProperties()));
+ old.remove( DirectoryWatcher.FILENAME );
+ old.remove( Constants.SERVICE_PID );
+ old.remove( ConfigurationAdmin.SERVICE_FACTORYPID );
+
+ if( !ht.equals( old ) )
{
- config.setBundleLocation(null);
+ ht.put(DirectoryWatcher.FILENAME, f.getAbsolutePath());
+ if (config.getBundleLocation() != null)
+ {
+ config.setBundleLocation(null);
+ }
+ config.update(ht);
+ return true;
}
- config.update(ht);
- return true;
+ else
+ {
+ return false;
+ }
}
/**
diff --git a/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/ConfigInstallerTest.java b/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/ConfigInstallerTest.java
index 6d0095f..e1c5de5 100644
--- a/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/ConfigInstallerTest.java
+++ b/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/ConfigInstallerTest.java
@@ -170,6 +170,8 @@
{
mockConfiguration.getBundleLocation();
mockConfigurationControl.setReturnValue( null );
+ mockConfiguration.getProperties();
+ mockConfigurationControl.setReturnValue( new Hashtable() );
mockConfiguration.update( new Hashtable() );
mockConfigurationControl.setMatcher( new ArgumentsMatcher()
{