Fix the issue Felix-626.
Create an empty Hashtable when parsing an empty aggregate property element. This allows specifying empty dictionaries inside instance configurations. The instance configuration, then, receives an empty dictionary for this property.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@674783 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
index 833be9c..e98fff2 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
@@ -104,7 +104,7 @@
* Parse a property.
* @param prop : the current element to parse
* @param dict : the dictionary to populate
- * @throws ParseException : occurs if the proeprty cannot be parsed correctly
+ * @throws ParseException : occurs if the property cannot be parsed correctly
*/
private void parseProperty(Element prop, Dictionary dict) throws ParseException {
// Check that the property has a name
@@ -118,13 +118,15 @@
// Recursive case
// Check if there is 'property' element
Element[] subProps = prop.getElements("property");
- if (subProps.length == 0) {
- throw new ParseException("A complex property must have at least one 'property' sub-element");
- }
- Dictionary dict2 = new Properties();
- for (int i = 0; i < subProps.length; i++) {
- parseProperty(subProps[i], dict2);
- dict.put(name, dict2);
+ if (subProps != null) {
+ Dictionary dict2 = new Properties();
+ for (int i = 0; i < subProps.length; i++) {
+ parseProperty(subProps[i], dict2);
+ dict.put(name, dict2);
+ }
+ } else {
+ // If the no sub-properties, inject an empty dictionary.
+ dict.put(name, new Properties());
}
} else {
dict.put(prop.getAttribute("name"), prop.getAttribute("value"));