diff options
author | Thomas Watson | 2020-09-02 18:24:36 +0000 |
---|---|---|
committer | Thomas Watson | 2020-09-04 13:04:33 +0000 |
commit | 0072515f5bad073515f892bbdab40099ec9c0d3b (patch) | |
tree | f862a0f340e4100b63a52fce78cf968f50da369a | |
parent | 44d6f423dfcda15f79148272053f66b06e244760 (diff) | |
download | rt.equinox.framework-0072515f5bad073515f892bbdab40099ec9c0d3b.tar.gz rt.equinox.framework-0072515f5bad073515f892bbdab40099ec9c0d3b.tar.xz rt.equinox.framework-0072515f5bad073515f892bbdab40099ec9c0d3b.zip |
Bug 566618 - Avoid creating domain during wiring invalidation
There are scenarios where creating a domain will fail, for example if
the bundle file has been deleted. There is no need to create a domain
in the case of invalidating a wiring because we are just trying to clear
the permission cache of the existing domain when invalidating a wiring.
Change-Id: Icb5d2118a267d08192f3ead21991d1955d36d34f
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
3 files changed, 41 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java index b0e9ab909..73955d23e 100755 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java @@ -3723,4 +3723,39 @@ public class SystemBundleTests extends AbstractBundleTests { stop(equinox); } + + public void testDeleteBundleFile() throws IOException, BundleException { + File config = OSGiTestsActivator.getContext().getDataFile(getName()); + Equinox equinox = new Equinox( + Collections.singletonMap(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath())); + + equinox.start(); + BundleContext bc = equinox.getBundleContext(); + + File b1File = createBundle(config, "b1", false, false); + bc.installBundle("reference:" + b1File.toURI().toASCIIString()).start(); + File b2File = createBundle(config, "b2", false, false); + bc.installBundle("reference:" + b2File.toURI().toASCIIString()).start(); + + stop(equinox); + + b1File.delete(); + b2File.delete(); + + Map<String, String> launchProps = new HashMap<>(); + launchProps.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); + SecurityManager sm = new SecurityManager() { + public void checkPermission(Permission perm) { + // do nothing; + } + }; + System.setSecurityManager(sm); + try { + equinox = new Equinox(Collections.singletonMap(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath())); + } finally { + System.setSecurityManager(null); + } + equinox.start(); + stop(equinox); + } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java index e6e3a6e34..43098b906 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java @@ -271,7 +271,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor { for (ModuleRevision revision : module.getRevisions().getModuleRevisions()) { Generation generation = (Generation) revision.getRevisionInfo(); if (generation != null) { - ProtectionDomain domain = generation.getDomain(); + ProtectionDomain domain = generation.getDomain(false); if (domain != null) { ((BundlePermissions) domain.getPermissions()).clearPermissionCache(); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java index ee5caae24..1d903dc81 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java @@ -317,11 +317,15 @@ public final class BundleInfo { } public ProtectionDomain getDomain() { + return getDomain(true); + } + + public ProtectionDomain getDomain(boolean create) { if (getBundleId() == 0 || System.getSecurityManager() == null) { return null; } synchronized (this.genMonitor) { - if (domain == null) { + if (domain == null && create) { if (revision == null) { throw new IllegalStateException("The revision is not yet set for this generation."); //$NON-NLS-1$ } |