Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2009-07-07 21:30:39 +0000
committerThomas Watson2009-07-07 21:30:39 +0000
commit6e2816461b9dfa5d8ba84b3f22cab346543b54ad (patch)
tree871295b6ad61f354bde6fb111757430b2566c63a
parent15b86fa636ce6148daace59bb254c369d1cfbc60 (diff)
downloadrt.equinox.framework-6e2816461b9dfa5d8ba84b3f22cab346543b54ad.tar.gz
rt.equinox.framework-6e2816461b9dfa5d8ba84b3f22cab346543b54ad.tar.xz
rt.equinox.framework-6e2816461b9dfa5d8ba84b3f22cab346543b54ad.zip
Deadlock possible between refreshPackages and BundleLoader initialization
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java31
1 files changed, 15 insertions, 16 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
index a675e924c..0457ccfb6 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java
@@ -202,17 +202,17 @@ public class PackageAdminImpl implements PackageAdmin {
framework.publishBundleEvent(Framework.BATCHEVENT_BEGIN, framework.systemBundle);
State systemState = framework.adaptor.getState();
BundleDescription[] descriptions = null;
- synchronized (framework.bundles) {
- int numBundles = bundles == null ? 0 : bundles.length;
- if (!refreshPackages)
- // in this case we must make descriptions non-null so we do
- // not force the removal pendings to be processed when resolving
- // the state.
- descriptions = new BundleDescription[0];
- else if (numBundles > 0) {
- // populate the resolved hosts package sources first
- populateLoaders(framework.bundles.getBundles());
- // not collect the descriptions to refresh
+ int numBundles = bundles == null ? 0 : bundles.length;
+ if (!refreshPackages)
+ // in this case we must make descriptions non-null so we do
+ // not force the removal pendings to be processed when resolving
+ // the state.
+ descriptions = new BundleDescription[0];
+ else if (numBundles > 0) {
+ // populate the resolved hosts package sources first (do this outside sync block: bug 280929)
+ populateLoaders(framework.getAllBundles());
+ synchronized (framework.bundles) {
+ // now collect the descriptions to refresh
ArrayList results = new ArrayList(numBundles);
BundleDelta[] addDeltas = null;
for (int i = 0; i < numBundles; i++) {
@@ -259,15 +259,14 @@ public class PackageAdminImpl implements PackageAdmin {
}
}
- private void populateLoaders(List bundles) {
+ private void populateLoaders(AbstractBundle[] bundles) {
// populate all the loaders with their package source information
// this is needed to fix bug 259903.
- for (Iterator iBundles = bundles.listIterator(); iBundles.hasNext();) {
- AbstractBundle bundle = (AbstractBundle) iBundles.next();
+ for (int i = 0; i < bundles.length; i++) {
// only need to do this for host bundles which are resolved
- if (bundle instanceof BundleHost && bundle.isResolved()) {
+ if (bundles[i] instanceof BundleHost && bundles[i].isResolved()) {
// getting the BundleLoader object populates the require-bundle sources
- BundleLoader loader = ((BundleHost) bundle).getBundleLoader();
+ BundleLoader loader = ((BundleHost) bundles[i]).getBundleLoader();
if (loader != null)
// need to explicitly get the import package sources
loader.getImportedSources(null);

Back to the top