Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-04-17 05:00:14 +0000
committerEike Stepper2016-04-17 05:00:14 +0000
commit5890a16b29787b4f04988fc1a30587eefc29e3c8 (patch)
treea7e3a29d77436942c0de34109c703eb73e33451a /plugins
parentbb06d61bf76e5be079ef500a33ce9c74ff998a7d (diff)
downloadcdo-5890a16b29787b4f04988fc1a30587eefc29e3c8.tar.gz
cdo-5890a16b29787b4f04988fc1a30587eefc29e3c8.tar.xz
cdo-5890a16b29787b4f04988fc1a30587eefc29e3c8.zip
[491499] CDOTransaction.postCommit fails to resolve direct resource
https://bugs.eclipse.org/bugs/show_bug.cgi?id=491499
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_491499_Test.java57
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java18
3 files changed, 74 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_491499_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_491499_Test.java
new file mode 100644
index 0000000000..5152872acb
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_491499_Test.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOState;
+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.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOObjectHandler;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * Bug 491499 - CDOTransaction.postCommit fails to resolve direct resource
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_491499_Test extends AbstractCDOTest
+{
+ public void testObjectOrderWithObjectHandler() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource1 = transaction.createResource(getResourcePath("res1"));
+ for (int i = 0; i < 5000; i++)
+ {
+ resource1.getContents().add(getModel1Factory().createCompany());
+ }
+
+ CDOResource resource2 = transaction.createResource(getResourcePath("res2"));
+ resource2.getContents().addAll(resource1.getContents());
+
+ transaction.addObjectHandler(new CDOObjectHandler()
+ {
+ public void objectStateChanged(CDOView view, CDOObject object, CDOState oldState, CDOState newState)
+ {
+ if (newState == CDOState.CLEAN || newState == CDOState.NEW)
+ {
+ // Can lead to exception if not all committed objects are remapped!
+ object.cdoResource();
+ }
+ }
+ });
+
+ transaction.commit();
+ }
+}
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 09240f864c..c80de5cabe 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
@@ -3119,7 +3119,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> conflicts = //
- super.invalidate(allChangedObjects, allDetachedObjects, deltas, revisionDeltas, detachedObjects);
+ super.invalidate(allChangedObjects, allDetachedObjects, deltas, revisionDeltas, detachedObjects);
if (!allChangedObjects.isEmpty())
{
@@ -4051,10 +4051,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
if (!objects.isEmpty())
{
- for (CDOObject object : objects.values())
- {
- CDOStateMachine.INSTANCE.commit((InternalCDOObject)object, result);
- }
+ CDOStateMachine.INSTANCE.commit(objects, result);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
index 7855007f80..9764cac2d2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
@@ -11,6 +11,7 @@
*/
package org.eclipse.emf.internal.cdo.view;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
@@ -525,7 +526,20 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
}
}
- public void commit(InternalCDOObject object, CommitTransactionResult result)
+ public void commit(Map<CDOID, CDOObject> objects, CommitTransactionResult result)
+ {
+ for (CDOObject object : objects.values())
+ {
+ commitObject((InternalCDOObject)object, result);
+ }
+
+ for (CDOObject object : objects.values())
+ {
+ changeState((InternalCDOObject)object, CDOState.CLEAN);
+ }
+ }
+
+ private void commitObject(InternalCDOObject object, CommitTransactionResult result)
{
synchronized (getMonitor(object))
{
@@ -1059,8 +1073,6 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
InternalCDORevisionManager revisionManager = transaction.getSession().getRevisionManager();
revisionManager.addRevision(revision);
-
- changeState(object, CDOState.CLEAN);
}
}

Back to the top