diff options
author | Thomas Watson | 2009-05-20 19:06:14 +0000 |
---|---|---|
committer | Thomas Watson | 2009-05-20 19:06:14 +0000 |
commit | d4540aaf0c9dcedfddf18c2a8790c417bb115324 (patch) | |
tree | 6a561d7b7d54891dc11fecda90da69960fb51ef8 | |
parent | 1c660b47fa306d6f13eab457bedd4dfe4b47003b (diff) | |
download | rt.equinox.framework-d4540aaf0c9dcedfddf18c2a8790c417bb115324.tar.gz rt.equinox.framework-d4540aaf0c9dcedfddf18c2a8790c417bb115324.tar.xz rt.equinox.framework-d4540aaf0c9dcedfddf18c2a8790c417bb115324.zip |
Bug 266935 NullPointerException in org.eclipse.osgi.internal.module.ResolverImpl.unresolveBundle() during Initializing Java Toolingv20090520
2 files changed, 73 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java index 58ce874fd..addedf103 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java @@ -1786,7 +1786,7 @@ public class StateResolverTest extends AbstractStateTest { long id = 0; State state = buildEmptyState(); Dictionary[] props = new Dictionary[] {new Hashtable()}; - props[0].put("osgi.resolverMode", "development"); + props[0].put("osgi.resolverMode", "development"); //$NON-NLS-1$ //$NON-NLS-2$ state.setPlatformProperties(props); Hashtable manifest = new Hashtable(); @@ -3667,6 +3667,76 @@ public class StateResolverTest extends AbstractStateTest { } } + private State createBug266935State() throws BundleException { + State state = buildEmptyState(); + int bundleID = 0; + // test the selection algorithm of the resolver to pick the bundles which + // resolve the largest set of bundles; with fragments + Hashtable manifest = new Hashtable(); + manifest.clear(); + manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_SYMBOLICNAME, "a"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ + BundleDescription a = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++); + + manifest.clear(); + manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_SYMBOLICNAME, "b"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$ + manifest.put(Constants.REQUIRE_BUNDLE, "a"); //$NON-NLS-1$ + BundleDescription b = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++); + + state.addBundle(a); + state.addBundle(b); + + state.resolve(); + assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$ + assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$ + return state; + } + + private BundleDescription updateStateBug266935(State state, BundleDescription a) throws BundleException { + Hashtable manifest = new Hashtable(); + manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$ + manifest.put(Constants.BUNDLE_SYMBOLICNAME, a.getSymbolicName()); + manifest.put(Constants.BUNDLE_VERSION, a.getVersion().toString()); + BundleDescription newA = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), a.getBundleId()); + state.updateBundle(newA); + return newA; + } + + public void testBug266935_01() throws BundleException { + State state = createBug266935State(); + BundleDescription a = state.getBundle("a", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ + BundleDescription newA = updateStateBug266935(state, a); + state.removeBundle(a); + state.resolve(new BundleDescription[] {newA}); + } + + public void testBug266935_02() throws BundleException { + State state = createBug266935State(); + BundleDescription a = state.getBundle("a", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ + updateStateBug266935(state, a); + state.removeBundle(a); + state.resolve(new BundleDescription[] {a}); + } + + public void testBug266935_03() throws BundleException { + State state = createBug266935State(); + BundleDescription a = state.getBundle("a", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ + BundleDescription newA = updateStateBug266935(state, a); + state.removeBundle(newA); + state.resolve(new BundleDescription[] {newA}); + } + + public void testBug266935_04() throws BundleException { + State state = createBug266935State(); + BundleDescription a = state.getBundle("a", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ + BundleDescription newA = updateStateBug266935(state, a); + state.removeBundle(newA); + state.resolve(new BundleDescription[] {a}); + } + public static class CatchAllValue { public CatchAllValue(String s) { //do nothing diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java index 5f897d500..b64c0270d 100644 --- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java +++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java @@ -154,7 +154,8 @@ public abstract class StateImpl implements State { public boolean removeBundle(BundleDescription toRemove) { synchronized (this.monitor) { - if (!bundleDescriptions.remove((KeyedElement) toRemove)) + toRemove = (BundleDescription) bundleDescriptions.get((KeyedElement) toRemove); + if (toRemove == null || !bundleDescriptions.remove((KeyedElement) toRemove)) return false; resolvedBundles.remove((KeyedElement) toRemove); disabledBundles.remove(toRemove); |