Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-08-23 10:01:38 -0400
committerThomas Watson2006-08-23 10:01:38 -0400
commita8314112462fbfc0ef677fef1da0fed408fa02bf (patch)
tree8fa460e43ffb9927657786782a301aadde3223aa
parentd3c1fa525ccd85eb29a6c8ab42bf39c31904d6ca (diff)
downloadrt.equinox.framework-a8314112462fbfc0ef677fef1da0fed408fa02bf.tar.gz
rt.equinox.framework-a8314112462fbfc0ef677fef1da0fed408fa02bf.tar.xz
rt.equinox.framework-a8314112462fbfc0ef677fef1da0fed408fa02bf.zip
Bug 50178 [osgi] Double-Checked LockingR32x_v20060823
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java12
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java17
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java29
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java26
4 files changed, 33 insertions, 51 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
index f27da8cc2..e3582be2d 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleContextImpl.java
@@ -863,14 +863,10 @@ public class BundleContextImpl implements BundleContext, EventDispatcher {
public Object getService(org.osgi.framework.ServiceReference reference) {
checkValid();
- // TODO double-check lock (bug 50178)!!
- if (servicesInUse == null) {
- synchronized (contextLock) {
- if (servicesInUse == null) {
- // Cannot predict how many services a bundle will use, start with a small table.
- servicesInUse = new Hashtable(10);
- }
- }
+ synchronized (contextLock) {
+ if (servicesInUse == null)
+ // Cannot predict how many services a bundle will use, start with a small table.
+ servicesInUse = new Hashtable(10);
}
ServiceRegistrationImpl registration = ((ServiceReferenceImpl) reference).registration;
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
index ebec89395..6d99cfbfd 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java
@@ -526,17 +526,12 @@ public class BundleHost extends AbstractBundle {
return getLoaderProxy().getBundleLoader();
}
- protected BundleLoaderProxy getLoaderProxy() {
- // TODO double-check lock (bug 50178)!!
- if (proxy == null) {
- synchronized (this) {
- if (proxy == null) {
- BundleDescription bundleDescription = getBundleDescription();
- proxy = new BundleLoaderProxy(this, bundleDescription);
- bundleDescription.setUserObject(proxy);
- }
- }
- }
+ protected synchronized BundleLoaderProxy getLoaderProxy() {
+ if (proxy != null)
+ return proxy;
+ BundleDescription bundleDescription = getBundleDescription();
+ proxy = new BundleLoaderProxy(this, bundleDescription);
+ bundleDescription.setUserObject(proxy);
return proxy;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
index 0a657dcb7..0949e5347 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java
@@ -304,27 +304,20 @@ public class BundleLoader implements ClassLoaderDelegate {
return createClassLoader().getResources(name);
}
- final BundleClassLoader createClassLoader() {
- // TODO double-check lock (bug 50178)!!
+ final synchronized BundleClassLoader createClassLoader() {
if (classloader != null)
return classloader;
- synchronized (this) {
- if (classloader != null)
- return classloader;
-
- try {
- String[] classpath = bundle.getBundleData().getClassPath();
- if (classpath != null) {
- BundleClassLoader bcl = createBCLPrevileged(bundle.getProtectionDomain(), classpath);
- parent = getParentPrivileged(bcl);
- classloader = bcl;
- } else {
- bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, new BundleException(Msg.BUNDLE_NO_CLASSPATH_MATCH));
- }
- } catch (BundleException e) {
- bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
+ try {
+ String[] classpath = bundle.getBundleData().getClassPath();
+ if (classpath != null) {
+ BundleClassLoader bcl = createBCLPrevileged(bundle.getProtectionDomain(), classpath);
+ parent = getParentPrivileged(bcl);
+ classloader = bcl;
+ } else {
+ bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, new BundleException(Msg.BUNDLE_NO_CLASSPATH_MATCH));
}
-
+ } catch (BundleException e) {
+ bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
}
return classloader;
}
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
index 88bfbcb90..e5aa0c9a1 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoaderProxy.java
@@ -45,20 +45,18 @@ public class BundleLoaderProxy implements RequiredBundle {
this.pkgSources = new KeyedHashSet(false);
}
- BundleLoader getBundleLoader() {
- // TODO double-check lock (bug 50178)!!
- if (loader == null && bundle.isResolved()) {
- synchronized (this) {
- if (loader == null)
- try {
- if (bundle.getBundleId() == 0) // this is the system bundle
- loader = new SystemBundleLoader(bundle, this);
- else
- loader = new BundleLoader(bundle, this);
- } catch (BundleException e) {
- bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
- return null;
- }
+ synchronized BundleLoader getBundleLoader() {
+ if (loader != null)
+ return loader;
+ if (bundle.isResolved()) {
+ try {
+ if (bundle.getBundleId() == 0) // this is the system bundle
+ loader = new SystemBundleLoader(bundle, this);
+ else
+ loader = new BundleLoader(bundle, this);
+ } catch (BundleException e) {
+ bundle.framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
+ return null;
}
}
return loader;

Back to the top