Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2017-11-15 11:32:18 -0500
committerThomas Watson2017-11-15 11:32:44 -0500
commit399ac521ec3043355fe1a0daa2bb0f0483c28605 (patch)
tree6a3bb9052c4b4805745a710cfadc846c77891fa8 /bundles
parentff045ea2ff997f4e4cf576d0dfb6c142b060f3f9 (diff)
downloadrt.equinox.framework-399ac521ec3043355fe1a0daa2bb0f0483c28605.tar.gz
rt.equinox.framework-399ac521ec3043355fe1a0daa2bb0f0483c28605.tar.xz
rt.equinox.framework-399ac521ec3043355fe1a0daa2bb0f0483c28605.zip
Bug 527302 - Issues installing bundles when a clean operation is initiated by StorageI20171115-2000
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java6
-rwxr-xr-xbundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java2
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/StorageHookTests.java20
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java4
4 files changed, 30 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java
index 3f68e6690..ec927f627 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/storage.hooks.a/org/eclipse/osgi/tests/hooks/framework/storage/a/TestHookConfigurator.java
@@ -39,7 +39,10 @@ public class TestHookConfigurator implements HookConfigurator {
@Override
public void load(Object loadContext, DataInputStream is) {
- // Nothing.
+ if (TestHookConfigurator.failLoad) {
+ // will force a clean
+ throw new IllegalArgumentException();
+ }
}
@Override
@@ -106,6 +109,7 @@ public class TestHookConfigurator implements HookConfigurator {
public static volatile boolean createStorageHookCalled;
public static volatile boolean invalid;
+ public static volatile boolean failLoad;
public static volatile boolean invalidFactoryClass;
public static volatile boolean validateCalled;
public static volatile boolean deletingGenerationCalled;
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 1df9950fa..40f6d98a8 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
@@ -2761,7 +2761,7 @@ public class SystemBundleTests extends AbstractBundleTests {
return bundles;
}
- static File createBundle(File outputDir, String id, boolean emptyManifest, boolean dirBundle) throws IOException {
+ public static File createBundle(File outputDir, String id, boolean emptyManifest, boolean dirBundle) throws IOException {
File file = new File(outputDir, "bundle" + id + (dirBundle ? "" : ".jar")); //$NON-NLS-1$ //$NON-NLS-2$
if (!dirBundle) {
JarOutputStream jos = new JarOutputStream(new FileOutputStream(file), createManifest(id, emptyManifest));
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/StorageHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/StorageHookTests.java
index ad52a358f..0a58c1724 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/StorageHookTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/StorageHookTests.java
@@ -18,6 +18,7 @@ import java.util.*;
import org.eclipse.osgi.container.ModuleContainerAdaptor.ModuleEvent;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.eclipse.osgi.tests.bundles.SystemBundleTests;
import org.osgi.framework.*;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.wiring.BundleRevision;
@@ -28,6 +29,7 @@ public class StorageHookTests extends AbstractFrameworkHookTests {
private static final String HOOK_CONFIGURATOR_BUNDLE = "storage.hooks.a";
private static final String HOOK_CONFIGURATOR_CLASS = "org.eclipse.osgi.tests.hooks.framework.storage.a.TestHookConfigurator";
private static final String HOOK_CONFIGURATOR_FIELD_CREATE_STORAGE_HOOK_CALLED = "createStorageHookCalled";
+ private static final String HOOK_CONFIGURATOR_FIELD_FAIL_LOAD = "failLoad";
private static final String HOOK_CONFIGURATOR_FIELD_INVALID = "invalid";
private static final String HOOK_CONFIGURATOR_FIELD_INVALID_FACTORY_CLASS = "invalidFactoryClass";
private static final String HOOK_CONFIGURATOR_FIELD_VALIDATE_CALLED = "validateCalled";
@@ -114,6 +116,18 @@ public class StorageHookTests extends AbstractFrameworkHookTests {
assertCreateStorageHookCalled();
}
+ public void testCleanOnFailLoad() throws Exception {
+ initAndStartFramework();
+ installBundle();
+ setFactoryHookFailLoad(true);
+ restartFramework();
+ assertBundleDiscarded();
+ // install a bundle without reference to test that the staging area is created correctly after clean
+ File bundlesBase = new File(OSGiTestsActivator.getContext().getDataFile(getName()), "bundles");
+ bundlesBase.mkdirs();
+ framework.getBundleContext().installBundle(SystemBundleTests.createBundle(bundlesBase, getName(), false, false).toURI().toString());
+ }
+
public void testDeletingGenerationCalledOnDiscard() throws Exception {
initAndStartFramework();
installBundle();
@@ -266,6 +280,7 @@ public class StorageHookTests extends AbstractFrameworkHookTests {
clazz.getField(HOOK_CONFIGURATOR_FIELD_INVALID_FACTORY_CLASS).set(null, false);
clazz.getField(HOOK_CONFIGURATOR_FIELD_DELETING_CALLED).set(null, false);
clazz.getField(HOOK_CONFIGURATOR_FIELD_ADAPT_MANIFEST).set(null, false);
+ clazz.getField(HOOK_CONFIGURATOR_FIELD_FAIL_LOAD).set(null, false);
}
private void restartFramework() throws Exception {
@@ -292,6 +307,11 @@ public class StorageHookTests extends AbstractFrameworkHookTests {
clazz.getField(HOOK_CONFIGURATOR_FIELD_REPLACE_BUILDER).set(null, value);
}
+ private void setFactoryHookFailLoad(boolean value) throws Exception {
+ Class<?> clazz = classLoader.loadClass(HOOK_CONFIGURATOR_CLASS);
+ clazz.getField(HOOK_CONFIGURATOR_FIELD_FAIL_LOAD).set(null, value);
+ }
+
private void updateBundle() throws Exception {
framework.getBundleContext().getBundle(location).update();
}
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 728585915..9548fe962 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
@@ -381,6 +381,10 @@ public class Storage {
if (location.isReadOnly() || !StorageUtil.rm(root, getConfiguration().getDebug().DEBUG_STORAGE)) {
equinoxContainer.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "The -clean (osgi.clean) option was not successful. Unable to clean the storage area: " + root.getAbsolutePath(), null); //$NON-NLS-1$
}
+ if (!location.isReadOnly()) {
+ // make sure to recreate to root folder
+ root.mkdirs();
+ }
}
public ModuleDatabase getModuleDatabase() {

Back to the top