Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-06-30 10:08:13 -0400
committerThomas Watson2016-06-30 10:47:30 -0400
commitadda20fca8b82495927ba45d158b53e22a5ca7f8 (patch)
tree6ef23090e37eed50e005631f1eb7bc30b43288a8
parent1688d6ad5ef4ed976fc044c2d28c76d1e463ca81 (diff)
downloadrt.equinox.framework-adda20fca8b82495927ba45d158b53e22a5ca7f8.tar.gz
rt.equinox.framework-adda20fca8b82495927ba45d158b53e22a5ca7f8.tar.xz
rt.equinox.framework-adda20fca8b82495927ba45d158b53e22a5ca7f8.zip
Bug 497092 - Use INFO event from uninstalled/updated bundle revisionI20160705-1600
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 c1127c9a7..8ea31cdb7 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
@@ -2745,7 +2745,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");
@@ -2754,6 +2754,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