Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2010-07-16 21:55:07 +0000
committerThomas Watson2010-07-16 21:55:07 +0000
commite67675fb52ca3024e267174588efce977ad1049f (patch)
tree4e728a888ddb25cf946a6e8d196fedf0a7dd472c /bundles
parentcf2c946e2dd916cf3144839a6f0be961f8ad57eb (diff)
downloadrt.equinox.framework-e67675fb52ca3024e267174588efce977ad1049f.tar.gz
rt.equinox.framework-e67675fb52ca3024e267174588efce977ad1049f.tar.xz
rt.equinox.framework-e67675fb52ca3024e267174588efce977ad1049f.zip
Bug 320124 - ArrayIndexOutOfBoundsException can occur when using bundle command in the console
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java58
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java8
2 files changed, 62 insertions, 4 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 a94f5ae4e..8329cfc88 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
@@ -3738,6 +3738,64 @@ public class StateResolverTest extends AbstractStateTest {
state.resolve(new BundleDescription[] {a});
}
+ public void testBug320124() throws BundleException {
+ State state = buildEmptyState();
+ int bundleID = 0;
+
+ 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.FRAGMENT_HOST, "a"); //$NON-NLS-1$
+ manifest.put(Constants.REQUIRE_BUNDLE, "d"); //$NON-NLS-1$
+ BundleDescription b = 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, "c"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ manifest.put(Constants.FRAGMENT_HOST, "a"); //$NON-NLS-1$
+ manifest.put(Constants.REQUIRE_BUNDLE, "e"); //$NON-NLS-1$
+ BundleDescription c = 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, "d"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ manifest.put(Constants.EXPORT_PACKAGE, "d"); //$NON-NLS-1$
+ BundleDescription d = 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, "e"); //$NON-NLS-1$
+ manifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ manifest.put(Constants.EXPORT_PACKAGE, "e"); //$NON-NLS-1$
+ BundleDescription e = state.getFactory().createBundleDescription(state, manifest, (String) manifest.get(Constants.BUNDLE_SYMBOLICNAME) + manifest.get(Constants.BUNDLE_VERSION), bundleID++);
+
+ state.addBundle(a);
+ state.addBundle(b);
+ state.addBundle(c);
+ state.addBundle(d);
+ state.addBundle(e);
+
+ state.resolve();
+ assertTrue("A is not resolved", a.isResolved()); //$NON-NLS-1$
+ assertTrue("B is not resolved", b.isResolved()); //$NON-NLS-1$
+ assertTrue("C is not resolved", c.isResolved()); //$NON-NLS-1$
+ assertTrue("D is not resolved", d.isResolved()); //$NON-NLS-1$
+
+ ExportPackageDescription[] visible = state.getStateHelper().getVisiblePackages(a, StateHelper.VISIBLE_INCLUDE_EE_PACKAGES | StateHelper.VISIBLE_INCLUDE_ALL_HOST_WIRES);
+
+ assertEquals("Wrong number of visible", 2, visible.length);
+ }
+
public static class CatchAllValue {
public CatchAllValue(String s) {
//do nothing
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
index 9a295c6d7..e4ee07b40 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* 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
@@ -559,9 +559,9 @@ class RequiresHolder {
for (int i = 0; i < fragments.length; i++) {
BundleSpecification[] fragmentRequiredBundles = fragments[i].getRequiredBundles();
for (int j = 0; j < fragmentRequiredBundles.length; j++) {
- if (resolved.contains(fragmentRequiredBundles[i].getSupplier())) {
- resolvedBundlesExported.put(fragmentRequiredBundles[i].getSupplier(), new Boolean(fragmentRequiredBundles[i].isExported()));
- resolved.remove(fragmentRequiredBundles[i].getSupplier());
+ if (resolved.contains(fragmentRequiredBundles[j].getSupplier())) {
+ resolvedBundlesExported.put(fragmentRequiredBundles[j].getSupplier(), new Boolean(fragmentRequiredBundles[j].isExported()));
+ resolved.remove(fragmentRequiredBundles[j].getSupplier());
}
}
if (resolved.size() == 0) {

Back to the top