Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-06-30 14:08:13 +0000
committerThomas Watson2016-07-08 16:29:18 +0000
commit0a14a26d8761f3e1440f09b0c28944b588d605c9 (patch)
treecef26eb65a0979093c418cac204eb6295f07f0a3
parent76a2bf690d7353a8c725894d31e59bc7a0b5c6e5 (diff)
downloadrt.equinox.framework-0a14a26d8761f3e1440f09b0c28944b588d605c9.tar.gz
rt.equinox.framework-0a14a26d8761f3e1440f09b0c28944b588d605c9.tar.xz
rt.equinox.framework-0a14a26d8761f3e1440f09b0c28944b588d605c9.zip
Bug 497092 - Use INFO event from uninstalled/updated bundle revision
If trying to open a zip file and an IOException is thrown then check if the bundle revision still exists in the list of revisions for the bundle. If it does not then the revision was removed as part of an uninstall or update operation. In this case just use an INFO event. Change-Id: I975061a2e963be1c7b9752401aae6d70eddda003 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java40
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java11
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java10
3 files changed, 59 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
index 8f4d2b15b..434e7f983 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java
@@ -21,6 +21,7 @@ import javax.xml.ws.Endpoint;
import javax.xml.ws.Service;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.osgi.internal.loader.ModuleClassLoader;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHook;
@@ -2198,4 +2199,43 @@ public class ClassLoadingBundleTests extends AbstractBundleTests {
getContext().removeBundleListener(delayB1);
}
}
+
+ public void testLoaderUninstalledBundle() throws BundleException, IOException {
+ String testResourcePath = "testResource";
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
+ Map<String, String> testHeaders = new HashMap<String, String>();
+ testHeaders.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ testHeaders.put(Constants.BUNDLE_SYMBOLICNAME, getName());
+ config.mkdirs();
+ File testBundleFile = SystemBundleTests.createBundle(config, getName(), testHeaders, Collections.singletonMap(testResourcePath, "testValue"));
+ Bundle test = getContext().installBundle(getName(), new FileInputStream(testBundleFile));
+ test.start();
+ BundleWiring wiring = test.adapt(BundleWiring.class);
+ assertNotNull("No wiring found.", wiring);
+ ModuleClassLoader bundleClassLoader = (ModuleClassLoader) wiring.getClassLoader();
+ URL testResource = bundleClassLoader.findLocalResource(testResourcePath);
+ assertNotNull("No test resource found.", testResource);
+
+ test.update(new FileInputStream(testBundleFile));
+ testResource = bundleClassLoader.findLocalResource(testResourcePath);
+ assertNull("Found resource.", testResource);
+
+ Object[] expectedFrameworkEvents = new Object[] {new FrameworkEvent(FrameworkEvent.INFO, test, null)};
+ Object[] actualFrameworkEvents = frameworkListenerResults.getResults(1);
+ compareResults(expectedFrameworkEvents, actualFrameworkEvents);
+
+ wiring = test.adapt(BundleWiring.class);
+ assertNotNull("No wiring found.", wiring);
+ bundleClassLoader = (ModuleClassLoader) wiring.getClassLoader();
+ testResource = bundleClassLoader.findLocalResource(testResourcePath);
+ assertNotNull("No test resource found.", testResource);
+
+ test.uninstall();
+
+ testResource = bundleClassLoader.findLocalResource(testResourcePath);
+ assertNull("Found resource.", testResource);
+
+ actualFrameworkEvents = frameworkListenerResults.getResults(1);
+ compareResults(expectedFrameworkEvents, actualFrameworkEvents);
+ }
}
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 46c96b7b9..983fabf9e 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
@@ -2746,7 +2746,7 @@ public class SystemBundleTests extends AbstractBundleTests {
return manifest;
}
- private static File createBundle(File outputDir, String bundleName, Map<String, String> headers) throws IOException {
+ static File createBundle(File outputDir, String bundleName, Map<String, String> headers, Map<String, String>... entries) throws IOException {
Manifest m = new Manifest();
Attributes attributes = m.getMainAttributes();
attributes.putValue("Manifest-Version", "1.0");
@@ -2755,6 +2755,15 @@ public class SystemBundleTests extends AbstractBundleTests {
}
File file = new File(outputDir, "bundle" + bundleName + ".jar"); //$NON-NLS-1$ //$NON-NLS-2$
JarOutputStream jos = new JarOutputStream(new FileOutputStream(file), m);
+ if (entries != null) {
+ for (Map<String, String> entryMap : entries) {
+ for (Map.Entry<String, String> entry : entryMap.entrySet()) {
+ jos.putNextEntry(new JarEntry(entry.getKey()));
+ jos.write(entry.getValue().getBytes());
+ jos.closeEntry();
+ }
+ }
+ }
jos.flush();
jos.close();
return file;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java
index 853ad370b..2f7816065 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java
@@ -67,7 +67,15 @@ public class ZipBundleFile extends BundleFile {
if (generation != null) {
ModuleRevision r = generation.getRevision();
if (r != null) {
- generation.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, r.getRevisions().getModule(), e);
+ ContainerEvent eventType = ContainerEvent.ERROR;
+ // If the revision has been removed from the list of revisions then it has been deleted
+ // because the bundle has been uninstalled or updated
+ if (!r.getRevisions().getModuleRevisions().contains(r)) {
+ // instead of filling the log with errors about missing files from
+ // uninstalled/updated bundles just give it an info level
+ eventType = ContainerEvent.INFO;
+ }
+ generation.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(eventType, r.getRevisions().getModule(), e);
}
}
// TODO not sure if throwing a runtime exception is better

Back to the top