Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2013-11-01 14:35:14 +0000
committerThomas Watson2013-11-01 14:37:09 +0000
commite0d4edbfc3a8e7bf77e4416cc0f608942d8d585a (patch)
treeaf07cd3c0d0295aebe15e5cf5b8541bdb451e773
parent73bc6822128ed7b6246f911276bcc4dbf491d0bf (diff)
downloadrt.equinox.framework-e0d4edbfc3a8e7bf77e4416cc0f608942d8d585a.tar.gz
rt.equinox.framework-e0d4edbfc3a8e7bf77e4416cc0f608942d8d585a.tar.xz
rt.equinox.framework-e0d4edbfc3a8e7bf77e4416cc0f608942d8d585a.zip
Bug 420830 - Attempts to install a bundle at an existing location does
full staging for no reason
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index 924a02c79..b6307553d 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -455,6 +455,33 @@ public class Storage {
} catch (Throwable e) {
throw new BundleException("Error reading bundle content.", e); //$NON-NLS-1$
}
+
+ // Check if the bundle already exists at this location
+ // before doing the staging and generation creation.
+ // This is important since some installers seem to continually
+ // re-install bundles using the same location each startup
+ Module existingLocation = moduleContainer.getModule(bundleLocation);
+ if (existingLocation != null) {
+ // NOTE this same logic is also in the ModuleContainer
+ // This is necessary because the container does the location locking.
+ // Another thread could win the location lock and install before this thread does.
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ if (origin != null) {
+ // Check that the existing location is visible from the origin module
+ Bundle bundle = origin.getBundle();
+ BundleContext context = bundle == null ? null : bundle.getBundleContext();
+ if (context != null && context.getBundle(existingLocation.getId()) == null) {
+ Bundle b = existingLocation.getBundle();
+ throw new BundleException(NLS.bind(Msg.ModuleContainer_NameCollisionWithLocation, new Object[] {b.getSymbolicName(), b.getVersion(), bundleLocation}), BundleException.REJECTED_BY_HOOK);
+ }
+ }
+ return (Generation) existingLocation.getCurrentRevision().getRevisionInfo();
+ }
+
boolean isReference = in instanceof ReferenceInputStream;
File staged = stageContent(in, sourceURL);
Generation generation = null;

Back to the top