Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2017-12-15 15:51:16 +0000
committerThomas Watson2017-12-15 15:51:16 +0000
commit4228f684eb8e2a17664dd6e3246650f4326be42d (patch)
tree49401f0cb931a87935cf0fffb255b8b40000f2d7
parent9b4f5003d023e28cea08b608f76ef953c065e255 (diff)
downloadrt.equinox.framework-4228f684eb8e2a17664dd6e3246650f4326be42d.tar.gz
rt.equinox.framework-4228f684eb8e2a17664dd6e3246650f4326be42d.tar.xz
rt.equinox.framework-4228f684eb8e2a17664dd6e3246650f4326be42d.zip
Bug 528777 - Unable to launch existing Eclipse application launch
configuration Need to make sure to discard modules with deleted/modified content before checking for multi-release bundles.
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java35
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java25
2 files changed, 49 insertions, 11 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java
index 5d9e8f82a..4f774b098 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/MultiReleaseJarTests.java
@@ -767,8 +767,8 @@ public class MultiReleaseJarTests extends AbstractBundleTests {
doTestMultiReleaseBundleManifestChangeRuntime(rv, configMap, location);
}
- equinox.start();
try {
+ equinox.start();
BundleContext systemContext = equinox.getBundleContext();
Bundle toUninstall = systemContext.getBundle(location);
toUninstall.uninstall();
@@ -829,4 +829,37 @@ public class MultiReleaseJarTests extends AbstractBundleTests {
}
}
+ public void testMultiReleaseBundleDeletedRestart() throws Exception {
+ File copyMrJarBundle = OSGiTestsActivator.getContext().getDataFile("copy-" + mrJarBundle.getName());
+ StorageUtil.readFile(new FileInputStream(mrJarBundle), copyMrJarBundle);
+
+ System.setProperty("java.specification.version", "9");
+
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
+ Map<String, String> configMap = Collections.singletonMap(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+ Equinox equinox = new Equinox(configMap);
+
+ try {
+ equinox.start();
+ BundleContext systemContext = equinox.getBundleContext();
+ Bundle mrBundle = systemContext.installBundle("reference:" + copyMrJarBundle.toURI().toString());
+ mrBundle.start();
+ } finally {
+ equinox.stop();
+ equinox.waitForStop(1000);
+ }
+
+ copyMrJarBundle.delete();
+
+ System.setProperty("java.specification.version", "10");
+
+ equinox = new Equinox(configMap);
+ try {
+ equinox.start();
+ } finally {
+ equinox.stop();
+ equinox.waitForStop(1000);
+ }
+ }
+
}
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 31b4b6fdb..4a1156ac8 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
@@ -151,7 +151,7 @@ public class Storage {
Storage storage = new Storage(container);
// Do some operations that need to happen on the fully constructed Storage before returning it
storage.checkSystemBundle();
- storage.discardBundlesOnLoad();
+ storage.refreshStaleBundles();
storage.installExtensions();
// TODO hack to make sure all bundles are in UNINSTALLED state before system bundle init is called
storage.getModuleContainer().setInitialModuleStates();
@@ -296,21 +296,30 @@ public class Storage {
return permData;
}
- private void discardBundlesOnLoad() throws BundleException {
- Collection<Module> discarded = new ArrayList<>(0);
+ private void refreshStaleBundles() throws BundleException {
+ Collection<Module> needsRefresh = new ArrayList<>(0);
+
+ // First uninstall any modules that had their content changed or deleted
for (Module module : moduleContainer.getModules()) {
if (module.getId() == Constants.SYSTEM_BUNDLE_ID)
continue;
ModuleRevision revision = module.getCurrentRevision();
Generation generation = (Generation) revision.getRevisionInfo();
if (needsDiscarding(generation)) {
- discarded.add(module);
+ needsRefresh.add(module);
moduleContainer.uninstall(module);
generation.delete();
}
}
- if (!discarded.isEmpty()) {
- moduleContainer.refresh(discarded);
+ // Next check if we need to refresh Multi-Release Jar bundles
+ // because the runtime version changed.
+ if (refreshMRBundles.get()) {
+ needsRefresh.addAll(refreshMRJarBundles());
+ }
+
+ // refresh the modules that got deleted or are Multi-Release bundles
+ if (!needsRefresh.isEmpty()) {
+ moduleContainer.refresh(needsRefresh);
}
}
@@ -371,10 +380,6 @@ public class Storage {
moduleContainer.resolve(Collections.singleton(systemModule), true);
}
}
- if (refreshMRBundles.get()) {
- Collection<Module> toRefresh = refreshMRJarBundles();
- moduleContainer.refresh(toRefresh);
- }
} catch (BundleException e) {
throw new IllegalStateException("Could not create a builder for the system bundle.", e); //$NON-NLS-1$
}

Back to the top