Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-06-06 13:48:41 +0000
committerThomas Watson2014-06-06 14:45:40 +0000
commit9d0e7ad4b198b56eae95572900a75f1e054f30c2 (patch)
treed57c5cd38920eb7a797d2706b8d2682c6970faf5 /bundles
parent9d2bb15935ea09709fdac55f5decf6940ef0f6d9 (diff)
downloadrt.equinox.framework-9d0e7ad4b198b56eae95572900a75f1e054f30c2.tar.gz
rt.equinox.framework-9d0e7ad4b198b56eae95572900a75f1e054f30c2.tar.xz
rt.equinox.framework-9d0e7ad4b198b56eae95572900a75f1e054f30c2.zip
Bug 436758 - Installing a bundle that requires Java 7 when running 6R4_4M20140709-0800I20140606-1215
with -clean cannot recover - Fixed by seeding the module database timestamps with the current time. This also impacted the check when loading persistent data into the database. There is a check to ensure loading persistent data can only happen on an empty database. The check used to check for zero timestamp value. This is never going to be true. I updated this to check for construction time instead. Change-Id: Ic5a79577476c6890235219aae829574f0060e385 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java32
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java15
2 files changed, 44 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
index bcfb46950..69df07323 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java
@@ -1070,6 +1070,38 @@ public class TestModuleContainer extends AbstractTest {
}
@Test
+ public void testTimestampSeeding() throws BundleException, IOException, InterruptedException {
+ Assert.assertNotEquals("The timestamps are the same!", createTestContainerAndGetTimestamp(), createTestContainerAndGetTimestamp());
+ }
+
+ private long createTestContainerAndGetTimestamp() throws BundleException, IOException, InterruptedException {
+ // wait here to ensure current time really has increased
+ Thread.sleep(100);
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+ DummyModuleDatabase database = adaptor.getDatabase();
+
+ Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
+
+ container.resolve(Arrays.asList(systemBundle), true);
+
+ // actually launch the container
+ systemBundle.start();
+
+ // install some bundles and set some settings
+ container.getFrameworkStartLevel().setInitialBundleStartLevel(2);
+ Module c4 = installDummyModule("c4_v1.MF", "c4_v1", container);
+ Module lazy1 = installDummyModule("lazy1_v1.MF", "lazy1", container);
+
+ container.resolve(Arrays.asList(c4, lazy1), true);
+
+ // set some settings
+ Assert.assertEquals("Wrong startlevel.", 2, c4.getStartLevel());
+ Assert.assertEquals("Wrong startlevel.", 2, lazy1.getStartLevel());
+ return database.getTimestamp();
+ }
+
+ @Test
public void testEventsStartLevelBeginningAt100() throws BundleException, IOException {
doTestEventsStartLevel(100);
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
index 57ed77d82..6d3a5bd4b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
@@ -97,6 +97,13 @@ public class ModuleDatabase {
*/
final AtomicLong allTimeStamp;
+ /**
+ * Holds the construction time which is used to check for empty database on
+ * load. This is necessary to ensure the loaded database is consistent with
+ * what was persisted.
+ */
+ final long constructionTime;
+
private final Capabilities capabilities;
/**
@@ -140,8 +147,10 @@ public class ModuleDatabase {
this.wirings = new HashMap<ModuleRevision, ModuleWiring>();
// Start at id 1 because 0 is reserved for the system bundle
this.nextId = new AtomicLong(1);
- this.revisionsTimeStamp = new AtomicLong(0);
- this.allTimeStamp = new AtomicLong(0);
+ // seed with current time to avoid duplicate timestamps after using -clean
+ this.constructionTime = System.currentTimeMillis();
+ this.revisionsTimeStamp = new AtomicLong(constructionTime);
+ this.allTimeStamp = new AtomicLong(constructionTime);
this.moduleSettings = new HashMap<Long, EnumSet<Settings>>();
this.capabilities = new Capabilities();
}
@@ -865,7 +874,7 @@ public class ModuleDatabase {
public final void load(DataInputStream in) throws IOException {
writeLock();
try {
- if (allTimeStamp.get() != 0)
+ if (allTimeStamp.get() != constructionTime)
throw new IllegalStateException("Can only load into a empty database."); //$NON-NLS-1$
Persistence.load(this, in);
} finally {

Back to the top