summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-03-10 03:12:36 (EST)
committerCaspar De Groot2011-03-10 03:12:36 (EST)
commitccdc3e9a1cc2dd537d2464b711ffc36a186c1fa1 (patch)
treef59d923784fe9070c66733fdce3b81eb90ed61e6
parent9217e2c014d554effbfc46dd6f9cbe4821ec69c4 (diff)
downloadcdo-ccdc3e9a1cc2dd537d2464b711ffc36a186c1fa1.zip
cdo-ccdc3e9a1cc2dd537d2464b711ffc36a186c1fa1.tar.gz
cdo-ccdc3e9a1cc2dd537d2464b711ffc36a186c1fa1.tar.bz2
[Bug 339461] 2nd partial commit of 2nd reattachment gives ConcurrentModificationEx
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339461
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java83
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java5
3 files changed, 89 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 fb19d13..77213b0 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
@@ -211,5 +211,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_336590_Test.class);
testClasses.add(Bugzilla_338884_Test.class);
testClasses.add(Bugzilla_338779_Test.class);
+ testClasses.add(Bugzilla_339461_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java
new file mode 100644
index 0000000..e3e2ace
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339461_Test.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2004 - 2011 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.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+import org.eclipse.emf.cdo.tests.model1.OrderDetail;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Caspar De Groot
+ */
+public class Bugzilla_339461_Test extends AbstractCDOTest
+{
+ public void test() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction tx = session.openTransaction();
+ CDOResource resource = tx.createResource(getResourcePath("test"));
+
+ Model1Factory factory = getModel1Factory();
+ Company company = factory.createCompany();
+ resource.getContents().add(company);
+
+ SalesOrder order1 = factory.createSalesOrder();
+ SalesOrder order2 = factory.createSalesOrder();
+ OrderDetail detail = factory.createOrderDetail();
+ order1.getOrderDetails().add(detail);
+ resource.getContents().add(order1);
+ resource.getContents().add(order2);
+ tx.commit();
+
+ order1.getOrderDetails().remove(detail);
+ order2.getOrderDetails().add(detail);
+
+ company.setName("dirty1"); // Ensures partial commit
+ tx.setCommittables(createSet(order1, order2, detail));
+ tx.commit();
+
+ order2.getOrderDetails().remove(detail);
+ order1.getOrderDetails().add(detail);
+
+ tx.setCommittables(createSet(order1, order2, detail));
+ tx.commit();
+
+ tx.close();
+ session.close();
+ }
+
+ private Set<EObject> createSet(EObject... objects)
+ {
+ Set<EObject> committables = new HashSet<EObject>();
+ for (EObject o : objects)
+ {
+ if (o == null)
+ {
+ throw new NullPointerException();
+ }
+
+ committables.add(o);
+ }
+
+ return committables;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index d9f7759..1818feb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -1707,6 +1707,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
formerRevisionKeys.remove(object);
}
+
+ for (CDOObject object : commitContext.getDirtyObjects().values())
+ {
+ formerRevisionKeys.remove(object);
+ }
}
// Reset partial-commit filter