diff options
author | Thomas Watson | 2015-07-23 14:50:26 +0000 |
---|---|---|
committer | Thomas Watson | 2015-07-23 15:22:44 +0000 |
commit | 340ebc87b394a075fa8920d00255f69b1ed6e4ab (patch) | |
tree | 64b7a53bc34430a87efb6ea64bbde13247b553d4 | |
parent | 4155be3c91ed53347dd88f898fd09d0390a0cbae (diff) | |
download | rt.equinox.bundles-340ebc87b394a075fa8920d00255f69b1ed6e4ab.tar.gz rt.equinox.bundles-340ebc87b394a075fa8920d00255f69b1ed6e4ab.tar.xz rt.equinox.bundles-340ebc87b394a075fa8920d00255f69b1ed6e4ab.zip |
Bug 468774 - NPE in org.eclipse.equinox.region whenI20150728-0800
installing/uninstalling bundles
4 files changed, 35 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java index 6910603d8..e021466f5 100644 --- a/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java +++ b/bundles/org.eclipse.equinox.region.tests/src/org/eclipse/equinox/region/tests/system/RegionSystemTests.java @@ -18,6 +18,7 @@ import java.util.*; import javax.management.*; import org.eclipse.equinox.region.*; import org.osgi.framework.*; +import org.osgi.framework.hooks.bundle.CollisionHook; import org.osgi.framework.hooks.resolver.ResolverHook; import org.osgi.framework.hooks.resolver.ResolverHookFactory; import org.osgi.framework.wiring.*; @@ -530,6 +531,33 @@ public class RegionSystemTests extends AbstractRegionSystemTest { } } + public void testBundleCollisionUninstalledBundle() throws BundleException { + Region region1 = digraph.createRegion(getName() + 1); + Region region2 = digraph.createRegion(getName() + 2); + Region region3 = digraph.createRegion(getName() + 3); + // install the same bundle into the first two regions. Should be no collision + bundleInstaller.installBundle(PP1, region1); + bundleInstaller.installBundle(PP1, region2); + + ServiceRegistration<CollisionHook> collisionHookREg = getContext().registerService(CollisionHook.class, new CollisionHook() { + @Override + public void filterCollisions(int operationType, Bundle target, Collection<Bundle> collisionCandidates) { + for (Bundle bundle : collisionCandidates) { + try { + bundle.uninstall(); + } catch (BundleException e) { + e.printStackTrace(); + } + } + } + }, new Hashtable<String, Object>(Collections.singletonMap(Constants.SERVICE_RANKING, Integer.MAX_VALUE))); + try { + bundleInstaller.installBundle(PP1, region3); + } finally { + collisionHookREg.unregister(); + } + } + public void testBundleCollisionConnectedRegions() throws BundleException, InvalidSyntaxException { // get the system region Region systemRegion = digraph.getRegion(0); diff --git a/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF index 65ffb6758..c1cbf460c 100644 --- a/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.region/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.equinox.region -Bundle-Version: 1.2.100.qualifier +Bundle-Version: 1.2.200.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Fragment-Host: system.bundle ExtensionBundle-Activator: org.eclipse.equinox.internal.region.RegionManager diff --git a/bundles/org.eclipse.equinox.region/pom.xml b/bundles/org.eclipse.equinox.region/pom.xml index c29f4c062..48c6b61a2 100644 --- a/bundles/org.eclipse.equinox.region/pom.xml +++ b/bundles/org.eclipse.equinox.region/pom.xml @@ -19,6 +19,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.region</artifactId> - <version>1.2.100-SNAPSHOT</version> + <version>1.2.200-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleCollisionHook.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleCollisionHook.java index 1ab76a934..860f89439 100644 --- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleCollisionHook.java +++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/hook/RegionBundleCollisionHook.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 VMware Inc. + * Copyright (c) 2011, 2015 VMware Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -68,6 +68,10 @@ public final class RegionBundleCollisionHook implements CollisionHook { // does not collide from the perspective of the collision candidate regions for (Bundle collisionCandidate : collisionCandidates) { Region candidateRegion = regionDigraph.getRegion(collisionCandidate); + if (candidateRegion == null) { + // we assume the candidate has been uninstalled; do not consider the candidate as a collision + continue; + } // we know the collision candidates all have the BSN/Version that collide. // we use the collision candidate and pretend it is part of the target region // to see if we can see it from the candidateRegion |