felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r962541 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
Date Fri, 09 Jul 2010 14:14:15 GMT
Author: rickhall
Date: Fri Jul  9 14:14:15 2010
New Revision: 962541

URL: http://svn.apache.org/viewvc?rev=962541&view=rev
Log:
Strip unknown attributes from Fragment-Host header. (FELIX-2466)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=962541&r1=962540&r2=962541&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
Fri Jul  9 14:14:15 2010
@@ -1142,23 +1142,28 @@ public class ManifestParser
                             + headerMap.get(Constants.FRAGMENT_HOST));
                 }
 
-                // If the bundle version matching attribute is specified, then
-                // convert it to the proper type.
-                for (int attrIdx = 0;
-                    attrIdx < clauses.get(0).m_attrs.size();
-                    attrIdx++)
+                // Strip all attributes other than bundle-version.
+                for (Iterator<Attribute> it = clauses.get(0).m_attrs.iterator(); it.hasNext();
)
                 {
-                    Attribute attr = clauses.get(0).m_attrs.get(attrIdx);
-                    if (attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
+                    Attribute attr = it.next();
+                    if (!attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     {
-                        clauses.get(0).m_attrs.set(attrIdx,
-                            new Attribute(
-                                Constants.BUNDLE_VERSION_ATTRIBUTE,
-                                VersionRange.parse(attr.getValue().toString()),
-                                attr.isMandatory()));
+                        it.remove();
                     }
                 }
 
+                // If the bundle-version attribute is specified, then convert
+                // it to the proper type.
+                if (clauses.get(0).m_attrs.size() == 1)
+                {
+                    Attribute attr = clauses.get(0).m_attrs.get(0);
+                    clauses.get(0).m_attrs.set(0,
+                        new Attribute(
+                            Constants.BUNDLE_VERSION_ATTRIBUTE,
+                            VersionRange.parse(attr.getValue().toString()),
+                            attr.isMandatory()));
+                }
+
                 // Prepend the host symbolic name to the array of attributes.
                 List<Attribute> attrs = clauses.get(0).m_attrs;
                 List<Attribute> newAttrs = new ArrayList<Attribute>(attrs.size()
+ 1);



Mime
View raw message