diff options
author | Thomas Watson | 2010-03-17 20:47:05 +0000 |
---|---|---|
committer | Thomas Watson | 2010-03-17 20:47:05 +0000 |
commit | d2e99ea826860c8301f1f800d9c5a6899a5edca1 (patch) | |
tree | 0bcac00103aad6f19ad8a217778810868d485200 /bundles/org.eclipse.osgi | |
parent | 8d36b08b86861c6b7c10f90c9b7e6af37943dc7a (diff) | |
download | rt.equinox.framework-d2e99ea826860c8301f1f800d9c5a6899a5edca1.tar.gz rt.equinox.framework-d2e99ea826860c8301f1f800d9c5a6899a5edca1.tar.xz rt.equinox.framework-d2e99ea826860c8301f1f800d9c5a6899a5edca1.zip |
Bug 306219 - Deadlock on startup using Java 2 security on WAS
Diffstat (limited to 'bundles/org.eclipse.osgi')
-rw-r--r-- | bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java index 0b068c3f2..cbea15e77 100644 --- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java +++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/permadmin/PermissionInfoCollection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. + * Copyright (c) 2008, 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 @@ -53,20 +53,28 @@ public final class PermissionInfoCollection extends PermissionCollection { public boolean implies(Permission perm) { if (hasAllPermission) return true; + Class permClass = perm.getClass(); PermissionCollection collection; synchronized (cachedPermissionCollections) { - Class permClass = perm.getClass(); collection = (PermissionCollection) cachedPermissionCollections.get(permClass); - if (collection == null) { - collection = perm.newPermissionCollection(); - if (collection == null) - collection = new PermissionsHash(); - try { - addPermissions(collection, permClass); - } catch (Exception e) { - throw (SecurityException) new SecurityException("Exception creating permissions: " + e.getClass().getName() + ": " + e.getMessage()).initCause(e); //$NON-NLS-1$ //$NON-NLS-2$ - } - cachedPermissionCollections.put(permClass, collection); + } + // must populate the collection outside of the lock to prevent class loader deadlock + if (collection == null) { + collection = perm.newPermissionCollection(); + if (collection == null) + collection = new PermissionsHash(); + try { + addPermissions(collection, permClass); + } catch (Exception e) { + throw (SecurityException) new SecurityException("Exception creating permissions: " + e.getClass().getName() + ": " + e.getMessage()).initCause(e); //$NON-NLS-1$ //$NON-NLS-2$ + } + synchronized (cachedPermissionCollections) { + // check to see if another thread beat this thread at adding the collection + PermissionCollection exists = (PermissionCollection) cachedPermissionCollections.get(permClass); + if (exists != null) + collection = exists; + else + cachedPermissionCollections.put(permClass, collection); } } return collection.implies(perm); |