The repository impl now ignores extra metadata in the XML file. Also fixed
a bug in the requirement impl that could lead to a NPE when comparing
requirements with null comments.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@396876 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryImpl.java b/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryImpl.java
index c4ca31d..ca73ecf 100644
--- a/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryImpl.java
+++ b/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RepositoryImpl.java
@@ -108,6 +108,16 @@
}
}
+ /**
+ * Default setter method when setting parsed data from the XML file,
+ * which currently ignores everything.
+ **/
+ protected Object put(Object key, Object value)
+ {
+ // Ignore everything for now.
+ return null;
+ }
+
private void parseRepositoryFile(int hopCount)
{
// TODO: OBR - Implement hop count.
@@ -145,13 +155,17 @@
}
};
+ // Get default setter method for Repository.
+ Method repoSetter = RepositoryImpl.class.getDeclaredMethod(
+ "put", new Class[] { Object.class, Object.class });
+
// Get default setter method for Resource.
- Method resourceSetter = ResourceImpl.class.getDeclaredMethod(
+ Method resSetter = ResourceImpl.class.getDeclaredMethod(
"put", new Class[] { Object.class, Object.class });
// Map XML tags to types.
- handler.addType("repository", factory, Repository.class, null);
- handler.addType("resource", ResourceImpl.class, Resource.class, resourceSetter);
+ handler.addType("repository", factory, Repository.class, repoSetter);
+ handler.addType("resource", ResourceImpl.class, Resource.class, resSetter);
handler.addType("category", CategoryImpl.class, null, null);
handler.addType("require", RequirementImpl.class, Requirement.class, null);
handler.addType("capability", CapabilityImpl.class, Capability.class, null);
diff --git a/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java b/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java
index d1f6e95..b959f74 100644
--- a/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java
+++ b/org.apache.felix.bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java
@@ -118,7 +118,8 @@
(m_optional == r.isOptional()) &&
(m_multiple == r.isMultiple()) &&
m_filter.toString().equals(r.getFilter()) &&
- m_comment.equals(r.getComment());
+ ((m_comment == r.getComment()) ||
+ ((m_comment != null) && (m_comment.equals(r.getComment()))));
}
return false;
}