aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1738988 - /aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixRequirementAdapter.java
Date Wed, 13 Apr 2016 18:51:37 GMT
Author: jwross
Date: Wed Apr 13 18:51:37 2016
New Revision: 1738988

URL: http://svn.apache.org/viewvc?rev=1738988&view=rev
Log:
[ARIES-1522] NullPointerException (NPE) when creating a RequireBundleHeader using the filter
provided by FelixRequirementAdapter.

When adapting a requirement in the "bundle" namespace from OBR, the adapter must replace "symbolicname"
with "osgi.wiring.bundle" and "version" with "bundle-version" in the filter.

Modified:
    aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixRequirementAdapter.java

Modified: aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixRequirementAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixRequirementAdapter.java?rev=1738988&r1=1738987&r2=1738988&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixRequirementAdapter.java
(original)
+++ aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixRequirementAdapter.java
Wed Apr 13 18:51:37 2016
@@ -19,6 +19,7 @@ import java.util.Map;
 
 import org.apache.aries.subsystem.obr.internal.AbstractRequirement;
 import org.apache.aries.subsystem.obr.internal.NamespaceTranslator;
+import org.osgi.framework.namespace.BundleNamespace;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Namespace;
 import org.osgi.resource.Resource;
@@ -63,11 +64,17 @@ public class FelixRequirementAdapter ext
 		/* (1) The Felix OBR specific "mandatory:<*" syntax must be stripped out of the filter.
 		 * (2) The namespace must be translated.
 		 */
-		result.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, requirement.getFilter()
+		String namespace = getNamespace();
+		String filter = requirement.getFilter()
 				.replaceAll("\\(mandatory\\:\\<\\*[^\\)]*\\)", "")
 				.replaceAll("\\(service\\=[^\\)]*\\)", "")
 				.replaceAll("objectclass", "objectClass")
-				.replaceAll(requirement.getName() + '=', getNamespace() + '='));
+				.replaceAll(requirement.getName() + '=', namespace + '=');
+		if (BundleNamespace.BUNDLE_NAMESPACE.equals(namespace)) {
+			filter = filter.replaceAll("symbolicname", namespace)
+					.replaceAll("version", BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE);
+		}
+		result.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter);
 		result.put(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, requirement.isOptional() ? Namespace.RESOLUTION_OPTIONAL
: Namespace.RESOLUTION_MANDATORY);
 		result.put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, requirement.isMultiple() ? Namespace.CARDINALITY_MULTIPLE
: Namespace.CARDINALITY_SINGLE);
 		return Collections.unmodifiableMap(result);



Mime
View raw message