FELIX-611 Do not return new configurations from the ConfigurationAdmin.listConfiguration
method and return null in case listConfiguration found no applicable configurations at all
(mandated by the spec, that null be returned and not an empty array)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@683144 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
index 11cb320..5caa37f 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
@@ -125,7 +125,7 @@
public Configuration[] listConfigurations( String filter ) throws IOException, InvalidSyntaxException
{
ConfigurationImpl ci[] = configurationManager.listConfigurations( this, filter );
- if ( ci == null )
+ if ( ci == null || ci.length == 0 )
{
return null;
}
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 d0632b7..28047c6 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
@@ -378,6 +378,12 @@
}
+ /**
+ * Returns <code>false</code> if this configuration contains configuration
+ * properties. Otherwise <code>true</code> is returned and this is a
+ * newly creted configuration object whose {@link #update(Dictionary)}
+ * method has never been called.
+ */
boolean isNew()
{
return properties == null;
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 a2fc2f8..16bde00 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
@@ -422,7 +422,11 @@
cfg = new ConfigurationImpl( this, pmList[i], config );
}
- configList.add( cfg );
+ // FELIX-611: Ignore configuration objects without props
+ if ( !cfg.isNew() )
+ {
+ configList.add( cfg );
+ }
}
}
}