You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/07/08 14:01:01 UTC

svn commit: r674783 - /felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java

Author: clement
Date: Tue Jul  8 05:01:01 2008
New Revision: 674783

URL: http://svn.apache.org/viewvc?rev=674783&view=rev
Log:
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.

Modified:
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java?rev=674783&r1=674782&r2=674783&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java Tue Jul  8 05:01:01 2008
@@ -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"));