Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-06-24 09:34:14 -0400
committerThomas Watson2016-06-24 09:34:30 -0400
commit5f042b16210f7e8662718a17b25c05a190224370 (patch)
tree03b2e22449d89bdde48c8e24fd19eb0c8097ad26
parentbf2dced9a01e1516ee0c44dcc37d855ba1b41811 (diff)
downloadrt.equinox.framework-5f042b16210f7e8662718a17b25c05a190224370.tar.gz
rt.equinox.framework-5f042b16210f7e8662718a17b25c05a190224370.tar.xz
rt.equinox.framework-5f042b16210f7e8662718a17b25c05a190224370.zip
Revert "Bug 496034 - Obtain readLock on ModuleDatabase before classLoaderMonitor"
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java50
1 files changed, 13 insertions, 37 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index 4e0f698dd..2e7f0e319 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -96,7 +96,7 @@ public class BundleLoader extends ModuleLoader {
private Object classLoaderMonitor = new Object();
/* @GuardedBy("classLoaderMonitor") */
- private volatile ModuleClassLoader classloader;
+ private ModuleClassLoader classloader;
private final ClassLoader parent;
private final AtomicBoolean triggerClassLoaded = new AtomicBoolean(false);
@@ -220,14 +220,8 @@ public class BundleLoader extends ModuleLoader {
}
public ModuleClassLoader getModuleClassLoader() {
- if (classloader != null) {
- return classloader;
- }
- // Need to obtain readlock on module database to prevent out of order locks that can happen
- // when a refresh operation (requiring write lock) closes a BundleLoader
- container.getStorage().getModuleDatabase().readLock();
- try {
- synchronized (classLoaderMonitor) {
+ synchronized (classLoaderMonitor) {
+ if (classloader == null) {
final List<ClassLoaderHook> hooks = container.getConfiguration().getHookRegistry().getClassLoaderHooks();
final Generation generation = (Generation) wiring.getRevision().getRevisionInfo();
if (System.getSecurityManager() == null) {
@@ -244,26 +238,17 @@ public class BundleLoader extends ModuleLoader {
for (ClassLoaderHook hook : hooks) {
hook.classLoaderCreated(classloader);
}
- return classloader;
}
- } finally {
- container.getStorage().getModuleDatabase().readUnlock();
+ return classloader;
}
}
@Override
protected void loadFragments(Collection<ModuleRevision> fragments) {
- // Need to obtain readlock on module database to prevent out of order locks that can happen
- // when a refresh operation (requiring write lock) closes a BundleLoader
- container.getStorage().getModuleDatabase().readLock();
- try {
- synchronized (classLoaderMonitor) {
- addFragmentExports(wiring.getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE));
- loadClassLoaderFragments(fragments);
- clearManifestLocalizationCache();
- }
- } finally {
- container.getStorage().getModuleDatabase().readUnlock();
+ synchronized (classLoaderMonitor) {
+ addFragmentExports(wiring.getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE));
+ loadClassLoaderFragments(fragments);
+ clearManifestLocalizationCache();
}
}
@@ -304,17 +289,10 @@ public class BundleLoader extends ModuleLoader {
policy.close(context);
}
}
- // Need to obtain readlock on module database to prevent out of order locks that can happen
- // when a refresh operation (requiring write lock) closes a BundleLoader
- container.getStorage().getModuleDatabase().readLock();
- try {
- synchronized (classLoaderMonitor) {
- if (classloader != null) {
- classloader.close();
- }
+ synchronized (classLoaderMonitor) {
+ if (classloader != null) {
+ classloader.close();
}
- } finally {
- container.getStorage().getModuleDatabase().readUnlock();
}
}
@@ -389,7 +367,7 @@ public class BundleLoader extends ModuleLoader {
String pkgName = getPackageName(name);
boolean bootDelegation = false;
// follow the OSGi delegation model
- if (checkParent && parent != null && container.isBootDelegationPackage(pkgName)) {
+ if (checkParent && parent != null && container.isBootDelegationPackage(pkgName))
// 2) if part of the bootdelegation list then delegate to parent and continue of failure
try {
return parent.loadClass(name);
@@ -397,7 +375,6 @@ public class BundleLoader extends ModuleLoader {
// we want to continue
bootDelegation = true;
}
- }
Class<?> result = null;
try {
result = (Class<?>) searchHooks(name, PRE_CLASS);
@@ -461,14 +438,13 @@ public class BundleLoader extends ModuleLoader {
return result;
// hack to support backwards compatibility for bootdelegation
// or last resort; do class context trick to work around VM bugs
- if (parent != null && !bootDelegation && ((checkParent && container.getConfiguration().compatibilityBootDelegation) || isRequestFromVM())) {
+ if (parent != null && !bootDelegation && ((checkParent && container.getConfiguration().compatibilityBootDelegation) || isRequestFromVM()))
// we don't need to continue if a CNFE is thrown here.
try {
return parent.loadClass(name);
} catch (ClassNotFoundException e) {
// we want to generate our own exception below
}
- }
throw new ClassNotFoundException(name + " cannot be found by " + this); //$NON-NLS-1$
}

Back to the top