diff options
author | Eike Stepper | 2010-06-03 08:35:20 +0000 |
---|---|---|
committer | Eike Stepper | 2010-06-03 08:35:20 +0000 |
commit | a912d89423507870d9aea0d1b7a6cf6769658d61 (patch) | |
tree | 286fc8b5e0ef902e941200d98f8f8337370ce257 /plugins | |
parent | 40d270055f38ccaf70d68a99a6f29ffeea040c00 (diff) | |
download | cdo-a912d89423507870d9aea0d1b7a6cf6769658d61.tar.gz cdo-a912d89423507870d9aea0d1b7a6cf6769658d61.tar.xz cdo-a912d89423507870d9aea0d1b7a6cf6769658d61.zip |
[315409] Missing Revsion Version Increment
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315409
Diffstat (limited to 'plugins')
6 files changed, 124 insertions, 17 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java index 2a72865c9e..a1841e4d4f 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ChangeSubscriptionTest.java @@ -12,7 +12,9 @@ package org.eclipse.emf.cdo.tests; import org.eclipse.emf.cdo.CDODeltaNotification; +import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.tests.model1.Category; @@ -26,6 +28,7 @@ import org.eclipse.emf.cdo.view.CDOView; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.spi.cdo.InternalCDOObject; @@ -816,6 +819,99 @@ public class ChangeSubscriptionTest extends AbstractCDOTest } /** + * See bug 315409. + */ + public void testInvalidationWithDeltas_SameBranch() throws Exception + { + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOView view = session.openView(); + + Company company = getModel1Factory().createCompany(); + company.setName("main-v1"); + + CDOResource resource = transaction.createResource("/test1"); + resource.getContents().add(company); + + transaction.commit(); + view.waitForUpdate(transaction.getLastCommitTime()); + + company.setName("main-v2"); + transaction.commit(); + view.waitForUpdate(transaction.getLastCommitTime()); + + view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL); + Company company2 = view.getObject(company); + company2.eAdapters().add(new AdapterImpl()); + + company.setName("main-v3"); + transaction.commit(); + view.waitForUpdate(transaction.getLastCommitTime()); + + CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision(); + assertEquals(3, revision2.getVersion()); + assertEquals(transaction.getBranch(), revision2.getBranch()); + assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp()); + + company.setName("main-v4"); + transaction.commit(); + view.waitForUpdate(transaction.getLastCommitTime()); + + revision2 = CDOUtil.getCDOObject(company2).cdoRevision(); + assertEquals(4, revision2.getVersion()); + assertEquals(transaction.getBranch(), revision2.getBranch()); + assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp()); + } + + /** + * See bug 315409. + */ + public void testInvalidationWithDeltas_SubBranch() throws Exception + { + skipTest(!getRepository().isSupportingBranches()); + + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + + Company company = getModel1Factory().createCompany(); + company.setName("main-v1"); + + CDOResource resource = transaction.createResource("/test1"); + resource.getContents().add(company); + + transaction.commit(); + + company.setName("main-v2"); + transaction.commit(); + + CDOBranch subBranch = transaction.getBranch().createBranch("SUB_BRANCH"); + transaction.setBranch(subBranch); + + CDOView view = session.openView(subBranch); + view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL); + Company company2 = view.getObject(company); + company2.eAdapters().add(new AdapterImpl()); + + company.setName("sub-v1"); + transaction.commit(); + view.waitForUpdate(transaction.getLastCommitTime()); + + CDORevision revision2 = CDOUtil.getCDOObject(company2).cdoRevision(); + assertEquals(1, revision2.getVersion()); + assertEquals(transaction.getBranch(), revision2.getBranch()); + assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp()); + + company.setName("sub-v2"); + transaction.commit(); + view.waitForUpdate(transaction.getLastCommitTime()); + + revision2 = CDOUtil.getCDOObject(company2).cdoRevision(); + assertEquals(2, revision2.getVersion()); + assertEquals(transaction.getBranch(), revision2.getBranch()); + assertEquals(transaction.getLastCommitTime(), revision2.getTimeStamp()); + } + + /** * @author Simon McDuff */ private class CDOIDFilterChangeSubscriptionPolicy implements CDOAdapterPolicy 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 0ec05ed7b7..75696765a0 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 @@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.tests; 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.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.internal.common.branch.CDOBranchImpl; @@ -608,7 +609,7 @@ public class StateMachineTest extends AbstractCDOTest CDOObject cdoObject = CDOUtil.getCDOObject(object); if (cdoObject != null) { - CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoObject, null); + CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoObject, null, CDOBranchPoint.UNSPECIFIED_DATE); } } 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 4eb385be9b..9988e7a245 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,6 +12,7 @@ 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; @@ -75,7 +76,7 @@ public class Bugzilla_252214_Test extends AbstractCDOTest CDOResource auditResource = audit.getResource("/res1"); Company auditCompany = (Company)auditResource.getContents().get(0); CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany); - CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null); + CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, null, CDOBranchPoint.UNSPECIFIED_DATE); } audit.setTimeStamp(commitTime2); 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 f680a2e5d7..187649adba 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 @@ -404,7 +404,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent /** * @since 3.0 */ - public void invalidate(InternalCDOObject object, CDORevisionKey key) + public void invalidate(InternalCDOObject object, CDORevisionKey key, long lastUpdateTime) { ReentrantLock lock = lockView(object.cdoView()); @@ -415,7 +415,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent trace(object, CDOEvent.INVALIDATE); } - process(object, CDOEvent.INVALIDATE, key); + process(object, CDOEvent.INVALIDATE, new Pair<CDORevisionKey, Long>(key, lastUpdateTime)); } finally { @@ -852,17 +852,22 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent /** * @author Eike Stepper */ - private class InvalidateTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, CDORevisionKey> + private class InvalidateTransition implements + ITransition<CDOState, CDOEvent, InternalCDOObject, Pair<CDORevisionKey, Long>> { - public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CDORevisionKey key) + public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Pair<CDORevisionKey, Long> keyAndTime) { + CDORevisionKey key = keyAndTime.getElement1(); + long lastUpdateTime = keyAndTime.getElement2(); InternalCDORevision oldRevision = object.cdoRevision(); if (key == null || key.getVersion() >= oldRevision.getVersion()) { + InternalCDOView view = object.cdoView(); if (key instanceof CDORevisionDelta) { CDORevisionDelta delta = (CDORevisionDelta)key; InternalCDORevision newRevision = oldRevision.copy(); + newRevision.adjustForCommit(view.getBranch(), lastUpdateTime); delta.apply(newRevision); object.cdoInternalSetRevision(newRevision); @@ -873,7 +878,6 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { changeState(object, CDOState.PROXY); - InternalCDOView view = object.cdoView(); CDOInvalidationPolicy policy = view.options().getInvalidationPolicy(); policy.handleInvalidation(object, key); object.cdoInternalPostInvalidate(); @@ -889,8 +893,9 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent private class ConflictTransition extends InvalidateTransition { @Override - public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CDORevisionKey key) + public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Pair<CDORevisionKey, Long> keyAndTime) { + CDORevisionKey key = keyAndTime.getElement1(); InternalCDORevision oldRevision = object.cdoRevision(); if (key == null || key.getVersion() >= oldRevision.getVersion() - 1) { @@ -907,7 +912,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, CDORevisionKey UNUSED) + public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Pair<CDORevisionKey, Long> UNUSED) { changeState(object, CDOState.INVALID_CONFLICT); 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 ec7064f900..04b52447f7 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 @@ -1804,8 +1804,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa * @since 3.0 */ @Override - protected Set<CDOObject> invalidate(List<CDORevisionKey> allChangedObjects, List<CDOIDAndVersion> allDetachedObjects, - List<CDORevisionDelta> deltas, Set<InternalCDOObject> changedObjects, Set<CDOObject> detachedObjects) + protected Set<CDOObject> invalidate(long lastUpdateTime, List<CDORevisionKey> allChangedObjects, + List<CDOIDAndVersion> allDetachedObjects, List<CDORevisionDelta> deltas, Set<InternalCDOObject> changedObjects, + Set<CDOObject> detachedObjects) { if (!allDetachedObjects.isEmpty()) { @@ -1822,7 +1823,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa removeCrossReferences(cachedNewObjects, referencedOIDs); } - return super.invalidate(allChangedObjects, allDetachedObjects, deltas, changedObjects, detachedObjects); + return super.invalidate(lastUpdateTime, allChangedObjects, allDetachedObjects, deltas, changedObjects, + detachedObjects); } private void removeCrossReferences(Collection<CDOObject> objects, Set<CDOID> referencedOIDs) 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 c2233bf152..7bd123e900 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 @@ -368,7 +368,7 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView if (existanceFlag) { // --> PROXY - CDOStateMachine.INSTANCE.invalidate(invalidObject, null); + CDOStateMachine.INSTANCE.invalidate(invalidObject, null, CDOBranchPoint.UNSPECIFIED_DATE); } else { @@ -1373,7 +1373,8 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView try { lock.lock(); - conflicts = invalidate(allChangedObjects, allDetachedObjects, deltas, changedObjects, detachedObjects); + conflicts = invalidate(lastUpdateTime, allChangedObjects, allDetachedObjects, deltas, changedObjects, + detachedObjects); } finally { @@ -1399,8 +1400,9 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView setLastUpdateTime(lastUpdateTime); } - protected Set<CDOObject> invalidate(List<CDORevisionKey> allChangedObjects, List<CDOIDAndVersion> allDetachedObjects, - List<CDORevisionDelta> deltas, Set<InternalCDOObject> changedObjects, Set<CDOObject> detachedObjects) + protected Set<CDOObject> invalidate(long lastUpdateTime, List<CDORevisionKey> allChangedObjects, + List<CDOIDAndVersion> allDetachedObjects, List<CDORevisionDelta> deltas, Set<InternalCDOObject> changedObjects, + Set<CDOObject> detachedObjects) { Set<CDOObject> conflicts = null; for (CDORevisionKey key : allChangedObjects) @@ -1423,7 +1425,7 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView { // if (!isLocked(changedObject)) { - CDOStateMachine.INSTANCE.invalidate(changedObject, key); + CDOStateMachine.INSTANCE.invalidate(changedObject, key, lastUpdateTime); } changedObjects.add(changedObject); |