Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-11-10 04:54:41 +0000
committerEike Stepper2012-11-10 04:54:41 +0000
commit92ceb671c1cdc8e0a3e3459844aac4723d266843 (patch)
tree2c324abdc17c0c2e5ff6f08888f8583b4c95bd7a
parent573add2b3bcb0ec6a799a665bdf91d07874e1ca8 (diff)
downloadcdo-92ceb671c1cdc8e0a3e3459844aac4723d266843.tar.gz
cdo-92ceb671c1cdc8e0a3e3459844aac4723d266843.tar.xz
cdo-92ceb671c1cdc8e0a3e3459844aac4723d266843.zip
[393958] InvalidateTransition creates wrong revision during branch
switch https://bugs.eclipse.org/bugs/show_bug.cgi?id=393958
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_369646_Test.java2
-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/AbstractCDOView.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java58
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java3
9 files changed, 56 insertions, 46 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
index 65e8d9c59b..bcf8dd8033 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
@@ -73,11 +73,11 @@ public abstract class BaseCDORevision extends AbstractCDORevision
private static final PerfTracer WRITING = new PerfTracer(OM.PERF_REVISION_WRITING, BaseCDORevision.class);
- private static final byte UNSET = 0;
+ private static final byte UNSET_OPCODE = 0;
- private static final byte SET_NULL = 1;
+ private static final byte SET_NULL_OPCODE = 1;
- private static final byte SET_NOT_NULL = 2;
+ private static final byte SET_NOT_NULL_OPCODE = 2;
private static final byte FROZEN_FLAG = 0x04;
@@ -858,7 +858,7 @@ public abstract class BaseCDORevision extends AbstractCDORevision
if (value == null)
{
// Feature is NOT set
- out.writeByte(UNSET);
+ out.writeByte(UNSET_OPCODE);
continue;
}
@@ -866,12 +866,12 @@ public abstract class BaseCDORevision extends AbstractCDORevision
if (value == CDORevisionData.NIL)
{
// Feature IS null
- out.writeByte(SET_NULL);
+ out.writeByte(SET_NULL_OPCODE);
continue;
}
// Feature is NOT null
- out.writeByte(SET_NOT_NULL);
+ out.writeByte(SET_NOT_NULL_OPCODE);
if (feature.isMany())
{
CDOList list = (CDOList)value;
@@ -907,10 +907,10 @@ public abstract class BaseCDORevision extends AbstractCDORevision
byte unsetState = in.readByte();
switch (unsetState)
{
- case UNSET:
+ case UNSET_OPCODE:
continue;
- case SET_NULL:
+ case SET_NULL_OPCODE:
setValue(i, CDORevisionData.NIL);
continue;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java
index c989c5f4a5..3f13222ed1 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java
@@ -102,7 +102,8 @@ public class LoadChunkIndication extends CDOServerReadIndication
MoveableList<Object> list = revision.getList(feature);
for (int i = fromIndex; i <= toIndex; i++)
{
- type.writeValue(out, list.get(i));
+ Object value = list.get(i);
+ type.writeValue(out, value);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java
index 0f3b12be47..73e9c8fc00 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/StateMachineTest.java
@@ -460,7 +460,7 @@ public class StateMachineTest extends AbstractCDOTest
CDOObject cdoObject = CDOUtil.getCDOObject(object);
if (cdoObject != null)
{
- CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoObject, null, CDOBranchPoint.UNSPECIFIED_DATE);
+ CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoObject, null);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java
index b70a457f8d..48c72cec7a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java
@@ -12,7 +12,6 @@
package org.eclipse.emf.cdo.tests.bugzilla;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -32,7 +31,7 @@ import java.util.Map;
* NPE when calling audit.setTimeStamp()
* <p>
* See bug 252214
- *
+ *
* @author Simon McDuff
*/
public class Bugzilla_252214_Test extends AbstractCDOTest
@@ -76,7 +75,7 @@ public class Bugzilla_252214_Test extends AbstractCDOTest
CDOResource auditResource = audit.getResource(getResourcePath("/res1"));
Company auditCompany = (Company)auditResource.getContents().get(0);
CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany);
- CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null, CDOBranchPoint.UNSPECIFIED_DATE);
+ CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null);
}
audit.setTimeStamp(commitTime2);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_369646_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_369646_Test.java
index b62afba0bb..5ad3ae0f7c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_369646_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_369646_Test.java
@@ -105,7 +105,7 @@ public class Bugzilla_369646_Test extends AbstractCDOTest
CDOSession session = openSession();
session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(1, 1));
- // Load the categroy in the resource (is now partially loaded)
+ // Load the category into the resource (is now partially loaded)
CDOView view = session.openView();
CDOResource res = view.getResource(getResourcePath("/test"));
Category cat = (Category)res.getContents().get(0);
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 a3ebbaa24e..a2a8327312 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
@@ -2310,8 +2310,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
* Synchronized through InvlidationRunner.run()
*/
@Override
- protected Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> invalidate(long lastUpdateTime,
- List<CDORevisionKey> allChangedObjects, List<CDOIDAndVersion> allDetachedObjects, List<CDORevisionDelta> deltas,
+ protected Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> invalidate(List<CDORevisionKey> allChangedObjects,
+ List<CDOIDAndVersion> allDetachedObjects, List<CDORevisionDelta> deltas,
Map<CDOObject, CDORevisionDelta> revisionDeltas, Set<CDOObject> detachedObjects)
{
if (!allDetachedObjects.isEmpty())
@@ -2336,8 +2336,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
session.clearCommittedSinceLastRefresh();
}
- return super.invalidate(lastUpdateTime, allChangedObjects, allDetachedObjects, deltas, revisionDeltas,
- detachedObjects);
+ return super.invalidate(allChangedObjects, allDetachedObjects, deltas, revisionDeltas, detachedObjects);
}
private void removeCrossReferences(Collection<CDOObject> referencers, Set<CDOID> referencedOIDs)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index 009eec6a0e..611a8d6bbe 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -1308,8 +1308,8 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
/*
* Synchronized through InvalidationRunner.run()
*/
- protected Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> invalidate(long lastUpdateTime,
- List<CDORevisionKey> allChangedObjects, List<CDOIDAndVersion> allDetachedObjects, List<CDORevisionDelta> deltas,
+ protected Map<CDOObject, Pair<CDORevision, CDORevisionDelta>> invalidate(List<CDORevisionKey> allChangedObjects,
+ List<CDOIDAndVersion> allDetachedObjects, List<CDORevisionDelta> deltas,
Map<CDOObject, CDORevisionDelta> revisionDeltas, Set<CDOObject> detachedObjects)
{
boolean hasConflictResolvers = this instanceof CDOTransaction
@@ -1338,7 +1338,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
changedObject.cdoRevision(), delta);
// if (!isLocked(changedObject))
{
- CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)changedObject, key, lastUpdateTime);
+ CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)changedObject, key);
}
revisionDeltas.put(changedObject, delta);
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 365e28ef23..4034c70b62 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
@@ -12,7 +12,6 @@
package org.eclipse.emf.internal.cdo.view;
import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.model.EMFUtil;
@@ -402,7 +401,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
/**
* @since 3.0
*/
- public void invalidate(InternalCDOObject object, CDORevisionKey key, long lastUpdateTime)
+ public void invalidate(InternalCDOObject object, CDORevisionKey key)
{
synchronized (getMonitor(object))
{
@@ -411,7 +410,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
trace(object, CDOEvent.INVALIDATE);
}
- process(object, CDOEvent.INVALIDATE, new Pair<CDORevisionKey, Long>(key, lastUpdateTime));
+ process(object, CDOEvent.INVALIDATE, key);
}
}
@@ -971,32 +970,47 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
/**
* @author Eike Stepper
*/
- private class InvalidateTransition implements
- ITransition<CDOState, CDOEvent, InternalCDOObject, Pair<CDORevisionKey, Long>>
+ private class InvalidateTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, CDORevisionKey>
{
- public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Pair<CDORevisionKey, Long> keyAndTime)
+ public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CDORevisionKey key)
{
- CDORevisionKey key = keyAndTime.getElement1();
InternalCDORevision oldRevision = object.cdoRevision();
- if (key == null || key.getVersion() >= oldRevision.getVersion())
+ InternalCDORevision newRevision = null;
+
+ InternalCDOView view = object.cdoView();
+ InternalCDORevisionCache cache = view.getSession().getRevisionManager().getCache();
+
+ if (SWITCHING_TARGET.get() == Boolean.TRUE)
{
- InternalCDOView view = object.cdoView();
+ CDORevisionDelta delta = (CDORevisionDelta)key;
+ CDORevisable target = delta.getTarget();
+ newRevision = (InternalCDORevision)cache.getRevisionByVersion(delta.getID(), target);
+ if (newRevision == null)
+ {
+ newRevision = oldRevision.copy();
+ view.getSession().resolveAllElementProxies(newRevision);
+ delta.apply(newRevision);
+ newRevision.setBranchPoint(target);
+ cache.addRevision(newRevision);
+ }
+
+ object.cdoInternalSetRevision(newRevision);
+ changeState(object, CDOState.CLEAN);
+ object.cdoInternalPostLoad();
+ return;
+ }
+ if (key == null || key.getVersion() >= oldRevision.getVersion())
+ {
CDORevisionKey newKey = null;
if (key != null)
{
- boolean switchingTarget = SWITCHING_TARGET.get() == Boolean.TRUE;
-
- int newVersion = getNewVersion(key, switchingTarget);
- CDOBranch newBranch = switchingTarget ? object.cdoView().getBranch() : key.getBranch();
-
- newKey = CDORevisionUtil.createRevisionKey(key.getID(), newBranch, newVersion);
+ int newVersion = getNewVersion(key);
+ newKey = CDORevisionUtil.createRevisionKey(key.getID(), key.getBranch(), newVersion);
}
- InternalCDORevision newRevision = null;
if (newKey != null)
{
- InternalCDORevisionCache cache = view.getSession().getRevisionManager().getCache();
newRevision = (InternalCDORevision)cache.getRevisionByVersion(newKey.getID(), newKey);
}
@@ -1017,7 +1031,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
}
}
- private int getNewVersion(CDORevisionKey key, boolean switchingTarget)
+ private int getNewVersion(CDORevisionKey key)
{
if (key instanceof CDORevisionDelta)
{
@@ -1029,8 +1043,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
}
}
- int increase = switchingTarget ? 0 : 1;
- return key.getVersion() + increase;
+ return key.getVersion() + 1;
}
}
@@ -1041,9 +1054,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
private class ConflictTransition extends InvalidateTransition
{
@Override
- public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Pair<CDORevisionKey, Long> keyAndTime)
+ public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CDORevisionKey key)
{
- CDORevisionKey key = keyAndTime.getElement1();
InternalCDORevision oldRevision = object.cdoRevision();
if (key == null || key.getVersion() >= oldRevision.getVersion() - 1)
{
@@ -1060,7 +1072,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
private final class InvalidConflictTransition extends ConflictTransition
{
@Override
- public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Pair<CDORevisionKey, Long> UNUSED)
+ public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CDORevisionKey UNUSED)
{
changeState(object, CDOState.INVALID_CONFLICT);
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 002f903a9b..d4dfeafd66 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
@@ -839,8 +839,7 @@ public class CDOViewImpl extends AbstractCDOView
Map<CDOObject, CDORevisionDelta> revisionDeltas = new HashMap<CDOObject, CDORevisionDelta>();
Set<CDOObject> detachedObjects = new HashSet<CDOObject>();
- conflicts = invalidate(lastUpdateTime, allChangedObjects, allDetachedObjects, deltas, revisionDeltas,
- detachedObjects);
+ conflicts = invalidate(allChangedObjects, allDetachedObjects, deltas, revisionDeltas, detachedObjects);
sendInvalidationNotifications(revisionDeltas.keySet(), detachedObjects);
fireInvalidationEvent(lastUpdateTime, Collections.unmodifiableMap(revisionDeltas),

Back to the top