Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2015-12-07 22:21:24 +0000
committerThomas Watson2015-12-07 22:21:24 +0000
commit37b7520f05fa9ce47db5376224a89384438fa150 (patch)
tree5c977295ae29bdf2ac49ecaaa85fc0f961c4abbf
parent0f8805c61ad64f8af27d5c5dee050460726b2f94 (diff)
downloadrt.equinox.framework-37b7520f05fa9ce47db5376224a89384438fa150.tar.gz
rt.equinox.framework-37b7520f05fa9ce47db5376224a89384438fa150.tar.xz
rt.equinox.framework-37b7520f05fa9ce47db5376224a89384438fa150.zip
Bug 483849 - Wires to capabilities provided by dynamically attached fragments are not recorded correctly in the host wiringI20151209-2300I20151209-2000I20151209-0800I20151208-2000I20151208-0800I20151207-2000
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java39
-rwxr-xr-xbundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.frag.MF6
-rwxr-xr-xbundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.host.MF5
-rwxr-xr-xbundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.importer.MF5
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java15
5 files changed, 63 insertions, 7 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index c7208bd4d..5af409b98 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -1987,6 +1987,45 @@ public class TestModuleContainer extends AbstractTest {
}
+ @Test
+ public void testBug483849() throws BundleException, IOException {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+
+ // install and resolve host bundle
+ Module host = installDummyModule("bug483849.host.MF", "host", container);
+ ResolutionReport report = container.resolve(Arrays.asList(host), true);
+ Assert.assertNull("Failed to resolve host.", report.getResolutionException());
+
+ // install and dynamically attach a fragment that exports a package and resolve an importer
+ Module frag = installDummyModule("bug483849.frag.MF", "frag", container);
+ Module importer = installDummyModule("bug483849.importer.MF", "importer", container);
+ report = container.resolve(Arrays.asList(frag, importer), true);
+ Assert.assertNull("Failed to resolve test fragment and importer.", report.getResolutionException());
+ // get the count of package exports
+ ModuleWiring wiring = host.getCurrentRevision().getWiring();
+ int originalPackageCnt = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).size();
+
+ // update the host to generate a new revision
+ Map<String, String> updateManifest = getManifest("bug483849.host.MF");
+ ModuleRevisionBuilder updateBuilder = OSGiManifestBuilderFactory.createBuilder(updateManifest);
+ container.update(host, updateBuilder, null);
+ // refresh host which should force the importer to re-resolve to the new revision
+ report = container.refresh(Collections.singleton(host));
+
+ ModuleWiring importerWiring = importer.getCurrentRevision().getWiring();
+ Assert.assertNotNull("No wiring for importer.", importerWiring);
+ List<ModuleWire> importerPackageWires = importerWiring.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
+ Assert.assertEquals("Wrong number of importer package Wires.", 1, importerPackageWires.size());
+
+ Assert.assertEquals("Wrong provider wiring.", host.getCurrentRevision().getWiring(), importerPackageWires.iterator().next().getProviderWiring());
+ Assert.assertEquals("Wrong provider revision.", host.getCurrentRevision(), importerPackageWires.iterator().next().getProviderWiring().getRevision());
+
+ wiring = host.getCurrentRevision().getWiring();
+ List<BundleCapability> packages = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
+ Assert.assertEquals("Wrong number of host packages.", originalPackageCnt, packages.size());
+ }
+
private static void assertWires(List<ModuleWire> required, List<ModuleWire>... provided) {
for (ModuleWire requiredWire : required) {
for (List<ModuleWire> providedList : provided) {
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.frag.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.frag.MF
new file mode 100755
index 000000000..27e59edd8
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.frag.MF
@@ -0,0 +1,6 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: frag
+Bundle-Version: 1.0.0
+Fragment-Host: host
+Export-Package: frag
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.host.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.host.MF
new file mode 100755
index 000000000..189aed1b2
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.host.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: host
+Bundle-Version: 1.0.0
+Export-Package: host
+
diff --git a/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.importer.MF b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.importer.MF
new file mode 100755
index 000000000..8a4c50f21
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/test_files/containerTests/bug483849.importer.MF
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: importer
+Bundle-Version: 1.0.0
+Import-Package: frag
+
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index cbde0281c..71ede6aa5 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -409,18 +409,12 @@ final class ModuleResolver {
private static ModuleWiring createWiringDelta(ModuleRevision revision, ModuleWiring existingWiring, Map<ModuleCapability, List<ModuleWire>> providedWireMap, List<ModuleWire> requiredWires) {
// No null checks are done here on the wires since this is a copy.
- // Create a ModuleWiring that only contains the new ordered list of provided wires
List<ModuleWire> existingProvidedWires = existingWiring.getProvidedModuleWires(null);
List<ModuleCapability> existingCapabilities = existingWiring.getModuleCapabilities(null);
- addProvidedWires(providedWireMap, existingProvidedWires, existingCapabilities);
-
- // Also need to include any new required wires that may have be added for fragment hosts
- // Also will be needed for dynamic imports
List<ModuleWire> existingRequiredWires = existingWiring.getRequiredModuleWires(null);
List<ModuleRequirement> existingRequirements = existingWiring.getModuleRequirements(null);
- addRequiredWires(requiredWires, existingRequiredWires, existingRequirements);
- // add newly resolved fragment capabilities and requirements
+ // First, add newly resolved fragment capabilities and requirements
if (providedWireMap != null) {
List<ModuleCapability> hostCapabilities = revision.getModuleCapabilities(HostNamespace.HOST_NAMESPACE);
ModuleCapability hostCapability = hostCapabilities.isEmpty() ? null : hostCapabilities.get(0);
@@ -430,6 +424,13 @@ final class ModuleResolver {
}
}
+ // Create a ModuleWiring that only contains the new ordered list of provided wires
+ addProvidedWires(providedWireMap, existingProvidedWires, existingCapabilities);
+
+ // Also need to include any new required wires that may have be added for fragment hosts
+ // Also will be needed for dynamic imports
+ addRequiredWires(requiredWires, existingRequiredWires, existingRequirements);
+
InternalUtils.filterCapabilityPermissions(existingCapabilities);
return new ModuleWiring(revision, existingCapabilities, existingRequirements, existingProvidedWires, existingRequiredWires, Collections.EMPTY_LIST);
}

Back to the top