summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-08 22:58:15 (EDT)
committerCaspar De Groot2010-08-08 22:58:15 (EDT)
commitc547d0fd2cb943b8fdfccb5733feca92e3e4403c (patch)
treea6d983e185dff467aad7ebe303a785a76bfa5370
parent39637a84031288c721223bf35e098eb523346902 (diff)
downloadcdo-c547d0fd2cb943b8fdfccb5733feca92e3e4403c.zip
cdo-c547d0fd2cb943b8fdfccb5733feca92e3e4403c.tar.gz
cdo-c547d0fd2cb943b8fdfccb5733feca92e3e4403c.tar.bz2
[322099] CDOViewImpl.getObject(CDOID, boolean) can return wrong object for temporary ID's
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322099
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java59
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java6
3 files changed, 67 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index f35c9ca..1f404f2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -81,6 +81,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_318844_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_318876_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_319836_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_320837_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_321699_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -225,6 +226,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_318876_Test.class);
testClasses.add(Bugzilla_319836_Test.class);
testClasses.add(Bugzilla_320837_Test.class);
+ testClasses.add(Bugzilla_321699_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java
new file mode 100644
index 0000000..610bd36
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321699_Test.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+/**
+ * Bug 321699 - CDOViewImpl.getObject(CDOID, boolean) can return wrong object for temporary IDs.
+ *
+ * @author Caspar De Groot
+ */
+public class Bugzilla_321699_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource("/r1");
+ msg("Pre-commit ID of resource = " + resource.cdoID());
+
+ CDOObject fetchedObject = tx.getObject(resource.cdoID());
+ assertSame(resource, fetchedObject);
+
+ tx.commit();
+
+ msg("Post-commit ID of resource = " + resource.cdoID());
+
+ Customer customer = Model1Factory.eINSTANCE.createCustomer();
+ resource.getContents().add(customer);
+ CDOID customerID = CDOUtil.getCDOObject(customer).cdoID();
+ msg("Pre-commit ID of customer = " + customerID);
+
+ fetchedObject = tx.getObject(customerID);
+
+ msg("Object fetched for customerID = " + fetchedObject);
+
+ assertSame(customer, fetchedObject);
+
+ tx.close();
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 1e40f6f..2e1e9bb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -1404,6 +1404,12 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
InternalCDOObject object = objects.remove(oldID);
newID = object.cdoID();
objects.put(newID, object);
+
+ if (lastLookupID == oldID)
+ {
+ lastLookupID = null;
+ lastLookupObject = null;
+ }
}
if (TRACER.isEnabled())