summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-07-20 04:39:00 (EDT)
committerCaspar De Groot2010-07-20 04:39:00 (EDT)
commitb257ebdf69272c69d10e0b2ef6a88c387ceece20 (patch)
tree42f2c81037f559e535fc0b3e704c8f2f4e92d7a3
parent3a196fa914278fa3442bf6829cd6aeb4faa0f60a (diff)
downloadcdo-b257ebdf69272c69d10e0b2ef6a88c387ceece20.zip
cdo-b257ebdf69272c69d10e0b2ef6a88c387ceece20.tar.gz
cdo-b257ebdf69272c69d10e0b2ef6a88c387ceece20.tar.bz2
[319836] Detach-reattach of dirty object discards pre-detach featureDeltas
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319836
-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_319836_Test.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java23
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java6
5 files changed, 31 insertions, 23 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 88c4e65..58c08a8 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_316444_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_318518_Test;
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.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -226,6 +227,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_318518_Test.class);
testClasses.add(Bugzilla_318844_Test.class);
testClasses.add(Bugzilla_318876_Test.class);
+ testClasses.add(Bugzilla_319836_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_319836_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
index 6ac1afa..00264d9 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
@@ -10,8 +10,10 @@
*/
package org.eclipse.emf.cdo.tests.bugzilla;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.server.IRepository.WriteAccessHandler;
import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
@@ -96,6 +98,11 @@ public class Bugzilla_319836_Test extends AbstractCDOTest
n3.getChildren().add(n2);
+ // Problem is with n2; the removal of its child has been lost
+ CDOID n2ID = CDOUtil.getCDOObject(n2).cdoID();
+ CDORevisionDelta revDelta = tr1.getRevisionDeltas().get(n2ID);
+ assertEquals(2, revDelta.getFeatureDeltas().size());
+
tr1.commit();
// Checks the tree.
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index d824241..40dd6ee 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -205,7 +205,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
private void attachOrReattach(InternalCDOObject object, InternalCDOTransaction transaction)
{
// Bug 283985 (Re-attachment)
- if (transaction.getFormerRevisions().containsKey(object))
+ if (transaction.getFormerRevisionKeys().containsKey(object))
{
reattachObject(object, transaction);
}
@@ -569,8 +569,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
InternalCDOTransaction transaction = transactionAndContents.getElement1();
List<InternalCDOObject> contents = transactionAndContents.getElement2();
- Map<InternalCDOObject, InternalCDORevision> formerRevisionMap = transaction.getFormerRevisions();
- boolean reattaching = formerRevisionMap.containsKey(object);
+ boolean reattaching = transaction.getFormerRevisionKeys().containsKey(object);
if (!reattaching)
{
@@ -681,9 +680,9 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, InternalCDOTransaction transaction)
{
InternalCDORevisionManager revisionManager = transaction.getSession().getRevisionManager();
- InternalCDORevision formerRevision = transaction.getFormerRevisions().get(object);
- CDOID id = formerRevision.getID();
+ CDORevisionKey revKey = transaction.getFormerRevisionKeys().get(object);
+ CDOID id = revKey.getID();
object.cdoInternalSetID(id);
object.cdoInternalSetView(transaction);
@@ -692,16 +691,15 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
InternalCDORevision revision = (InternalCDORevision)factory.createRevision(object.eClass());
revision.setID(id);
revision.setBranchPoint(transaction.getBranch().getHead());
- revision.setVersion(formerRevision.getVersion());
+ revision.setVersion(revKey.getVersion());
// Populate the revision based on the values in the CDOObject
object.cdoInternalSetRevision(revision);
object.cdoInternalPostAttach();
// Compute a revision delta and register it with the tx
- // CDOBranchVersion branchVersion = transaction.getBranch().getVersion(revision.getVersion());
- // CDORevision originalRevision = revisionManager.getRevisionByVersion(id, branchVersion, -1, true);
- CDORevisionDelta revisionDelta = CDORevisionDeltaUtil.create(formerRevision, revision);
+ CDORevision cleanRevision = revisionManager.getRevisionByVersion(id, revKey, -1, true);
+ CDORevisionDelta revisionDelta = CDORevisionDeltaUtil.create(cleanRevision, revision);
transaction.registerRevisionDelta(revisionDelta);
transaction.registerDirty(object, null);
changeState(object, CDOState.DIRTY);
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 b778fce..c181131 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
@@ -41,6 +41,7 @@ import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDeltaUtil;
@@ -139,7 +140,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
@@ -177,7 +177,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
private String commitComment;
// Bug 283985 (Re-attachment)
- private WeakHashMap<InternalCDOObject, InternalCDORevision> formerRevisions = new WeakHashMap<InternalCDOObject, InternalCDORevision>();
+ private Map<InternalCDOObject, CDORevisionKey> formerRevisionKeys = new HashMap<InternalCDOObject, CDORevisionKey>();
// Bug 283985 (Re-attachment)
private final ThreadLocal<Boolean> providingCDOID = new InheritableThreadLocal<Boolean>()
@@ -1168,9 +1168,10 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
else
{
getLastSavepoint().getDetachedObjects().put(id, object);
- if (!formerRevisions.containsKey(object))
+ if (!formerRevisionKeys.containsKey(object))
{
- formerRevisions.put(object, object.cdoRevision());
+ CDORevisionKey revKey = CDORevisionUtil.createRevisionKey(object.cdoRevision());
+ formerRevisionKeys.put(object, revKey);
}
// Object may have been reattached previously, in which case it must
@@ -1529,7 +1530,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
firstSavepoint.getSharedDetachedObjects().clear();
// Bug 283985 (Re-attachment)
- formerRevisions.clear();
+ formerRevisionKeys.clear();
dirty = false;
conflict = 0;
@@ -1756,9 +1757,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return lastSavepoint.getAllDetachedObjects();
}
- public Map<InternalCDOObject, InternalCDORevision> getFormerRevisions()
+ public Map<InternalCDOObject, CDORevisionKey> getFormerRevisionKeys()
{
- return formerRevisions;
+ return formerRevisionKeys;
}
@Override
@@ -1768,16 +1769,16 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
// The super implementation will return null for a transient (unattached) object;
// but in a tx, an transient object may previously have been attached, so we consult
- // the formerRevisions -- unless this is being called indirectly through provideCDOID.
+ // the formerIDs -- unless this is being called indirectly through provideCDOID.
// The latter case occurs when deltas or revisions are being written out to a stream; in
// which case null must be returned (for transients) so that the caller will detect a
// dangling reference
if (!providingCDOID.get().booleanValue() && id == null)
{
- CDORevision formerRevision = formerRevisions.get(object);
- if (formerRevision != null)
+ CDORevisionKey revKey = formerRevisionKeys.get(object);
+ if (revKey != null)
{
- id = formerRevision.getID();
+ id = revKey.getID();
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
index 4be5a97..19ac55d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
@@ -16,11 +16,11 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -88,9 +88,9 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
CDORevisionAvailabilityInfo targetInfo, CDORevisionAvailabilityInfo sourceInfo);
/**
- * @since 3.0
+ * @since 4.0
*/
- public Map<InternalCDOObject, InternalCDORevision> getFormerRevisions();
+ public Map<InternalCDOObject, CDORevisionKey> getFormerRevisionKeys();
/**
* @since 3.0