summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-08 22:41:16 (EDT)
committerCaspar De Groot2010-08-08 22:41:16 (EDT)
commitc998af19078971058b7aaf2ed14264a66797dd9e (patch)
tree27ca8597071b3bb11cd20b5f228b68cede21b7fe
parent7c61683878748494155fca557a6118f19ceb236e (diff)
downloadcdo-c998af19078971058b7aaf2ed14264a66797dd9e.zip
cdo-c998af19078971058b7aaf2ed14264a66797dd9e.tar.gz
cdo-c998af19078971058b7aaf2ed14264a66797dd9e.tar.bz2
[321699] CDOViewImpl.getObject(CDOID, boolean) can return wrong object for temporary ID's
https://bugs.eclipse.org/bugs/show_bug.cgi?id=321699
-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 90ff5e3..bf165c6 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
@@ -86,6 +86,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_318998_Tests;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_319836_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_320690_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;
@@ -236,6 +237,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_319836_Test.class);
testClasses.add(Bugzilla_320690_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 169cb6e..c1821d8 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
@@ -1412,6 +1412,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())