summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-11-14 22:35:31 (EST)
committerCaspar De Groot2010-11-14 22:35:31 (EST)
commitfdc39bcef6faa0c8591b7f652fc5e6f311e68878 (patch)
treeba769925a5d0f9f8d3d670243d63a17db473f523
parentd838c1011858929372a8f75610681d23ca0d5d1a (diff)
downloadcdo-fdc39bcef6faa0c8591b7f652fc5e6f311e68878.zip
cdo-fdc39bcef6faa0c8591b7f652fc5e6f311e68878.tar.gz
cdo-fdc39bcef6faa0c8591b7f652fc5e6f311e68878.tar.bz2
[328681] LockObjectsRequest can cause corruption of client-side graph
https://bugs.eclipse.org/bugs/show_bug.cgi?id=328681
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java5
-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/LockingManagerTest.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294850_Test.java121
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java32
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java7
11 files changed, 143 insertions, 207 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
index 6c6cd9c..66f2841 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
@@ -208,16 +208,15 @@ public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDO
}
}
- public RefreshSessionResult lockObjects(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, LockType lockType, long timeout)
- throws InterruptedException
+ public boolean lockObjects(List<InternalCDORevision> viewedRevisions, int viewID, CDOBranch viewedBranch,
+ LockType lockType, long timeout) throws InterruptedException
{
InterruptedException interruptedException = null;
RuntimeException runtimeException = null;
try
{
- return new LockObjectsRequest(this, lastUpdateTime, viewedRevisions, viewID, lockType, timeout).send();
+ return new LockObjectsRequest(this, viewedRevisions, viewID, viewedBranch, lockType, timeout).send();
}
catch (RemoteException ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java
index e22b164..b7f12fb 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java
@@ -11,21 +11,22 @@
package org.eclipse.emf.cdo.internal.net4j.protocol;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.util.concurrent.IRWLockManager;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import java.io.IOException;
-import java.util.Map;
+import java.util.List;
/**
* @author Eike Stepper
*/
-public class LockObjectsRequest extends RefreshSessionRequest
+public class LockObjectsRequest extends CDOClientRequest<Boolean>
{
private int viewID;
@@ -33,23 +34,43 @@ public class LockObjectsRequest extends RefreshSessionRequest
private long timeout;
- public LockObjectsRequest(CDOClientProtocol protocol, long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, IRWLockManager.LockType lockType,
- long timeout)
+ private List<InternalCDORevision> viewedRevisions;
+
+ /**
+ * The branch being viewed
+ */
+ private CDOBranch viewedBranch;
+
+ public LockObjectsRequest(CDOClientProtocol protocol, List<InternalCDORevision> viewedRevisions, int viewID,
+ CDOBranch viewedBranch, LockType lockType, long timeout)
{
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS, lastUpdateTime, viewedRevisions, CDORevision.UNCHUNKED,
- false);
+ super(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS);
+
this.viewID = viewID;
this.lockType = lockType;
this.timeout = timeout;
+ this.viewedRevisions = viewedRevisions;
+ this.viewedBranch = viewedBranch;
}
@Override
protected void requesting(CDODataOutput out) throws IOException
{
- super.requesting(out);
out.writeInt(viewID);
out.writeCDOLockType(lockType);
out.writeLong(timeout);
+ out.writeCDOBranch(viewedBranch);
+
+ out.writeInt(viewedRevisions.size());
+ for (CDORevision revision : viewedRevisions)
+ {
+ out.writeCDORevisionKey(revision);
+ }
+ }
+
+ @Override
+ protected Boolean confirming(CDODataInput in) throws IOException
+ {
+ return in.readBoolean();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java
index 04bd19c..8466f25 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java
@@ -8,16 +8,20 @@
* Contributors:
* Simon McDuff - initial API and implementation
* Eike Stepper - maintenance
+ * Caspar De Groot - maintenance
*/
package org.eclipse.emf.cdo.server.internal.net4j.protocol;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.server.InternalLockManager;
import org.eclipse.net4j.util.WrappedException;
@@ -30,14 +34,10 @@ import java.util.List;
/**
* @author Simon McDuff
*/
-public class LockObjectsIndication extends RefreshSessionIndication
+public class LockObjectsIndication extends CDOReadIndication
{
private List<Object> objectsToBeLocked = new ArrayList<Object>();
- private IView view;
-
- private LockType lockType;
-
public LockObjectsIndication(CDOServerProtocol protocol)
{
super(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS);
@@ -46,14 +46,21 @@ public class LockObjectsIndication extends RefreshSessionIndication
@Override
protected void indicating(CDODataInput in) throws IOException
{
- super.indicating(in);
int viewID = in.readInt();
- lockType = in.readCDOLockType();
+ LockType lockType = in.readCDOLockType();
long timeout = in.readLong();
+ CDOBranch viewedBranch = in.readCDOBranch();
- view = getSession().getView(viewID);
- InternalLockManager lockManager = getRepository().getLockManager();
+ int nRevisions = in.readInt();
+ CDORevisionKey[] revKeys = new CDORevisionKey[nRevisions];
+ for (int i = 0; i < nRevisions; i++)
+ {
+ revKeys[i] = in.readCDORevisionKey();
+ handleViewedRevision(viewedBranch, revKeys[i]);
+ }
+ IView view = getSession().getView(viewID);
+ InternalLockManager lockManager = getRepository().getLockManager();
try
{
lockManager.lock(lockType, view, objectsToBeLocked, timeout);
@@ -64,31 +71,40 @@ public class LockObjectsIndication extends RefreshSessionIndication
}
}
- @Override
- protected CDORevisionKey handleViewedRevision(CDOBranch branch, CDORevisionKey revision)
+ private void handleViewedRevision(CDOBranch viewedBranch, CDORevisionKey revKey)
{
+ // TODO (CD) I'm using IllegalArgExceptions here because that's how it worked before. But
+ // personally I don't think it makes a lot of sense to throw exceptions from #indicating or
+ // #responding when *expected* problems are detected, especially because they trigger
+ // a separate signal. Why not just report problems through the response stream?
+
+ CDOID id = revKey.getID();
+ InternalCDORevision rev = getRepository().getRevisionManager().getRevision(id, viewedBranch.getHead(),
+ CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, true);
+ if (rev == null)
+ {
+ throw new IllegalArgumentException(String.format("Object %s not found in branch %s (possibly detached)", id,
+ viewedBranch));
+ }
+ if (!revKey.equals(rev))
+ {
+ throw new IllegalArgumentException(String.format(
+ "Client's revision of object %s is not the latest version in branch %s", id, viewedBranch));
+ }
+
if (getRepository().isSupportingBranches())
{
- objectsToBeLocked.add(CDOIDUtil.createIDAndBranch(revision.getID(), branch));
+ objectsToBeLocked.add(CDOIDUtil.createIDAndBranch(id, viewedBranch));
}
else
{
- objectsToBeLocked.add(revision.getID());
+ objectsToBeLocked.add(id);
}
-
- return revision;
- }
-
- @Override
- protected void writeDetachedObject(CDODataOutput out, CDORevisionKey key) throws IOException
- {
- getRepository().getLockManager().unlock(lockType, view, objectsToBeLocked);
- throw new IllegalArgumentException("Object has been detached: " + key); //$NON-NLS-1$
}
@Override
- protected void respondingDone()
+ protected void responding(CDODataOutput out) throws IOException
{
- // Do nothing
+ out.writeBoolean(true);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java
index 7273095..d71fa4c 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java
@@ -80,17 +80,11 @@ public class RefreshSessionIndication extends CDOReadIndication
for (int j = 0; j < size; j++)
{
CDORevisionKey revision = in.readCDORevisionKey();
- revision = handleViewedRevision(branch, revision);
revisions.add(revision);
}
}
}
- protected CDORevisionKey handleViewedRevision(CDOBranch branch, CDORevisionKey revision)
- {
- return revision;
- }
-
@Override
protected void responding(CDODataOutput out) throws IOException
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
index 8f31c8a..a1186bc 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
@@ -304,9 +304,8 @@ public class EmbeddedClientSessionProtocol extends Lifecycle implements CDOSessi
throw new UnsupportedOperationException();
}
- public RefreshSessionResult lockObjects(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, LockType lockType, long timeout)
- throws InterruptedException
+ public boolean lockObjects(List<InternalCDORevision> viewedRevisions, int viewID, CDOBranch viewedBranch,
+ LockType lockType, long timeout) throws InterruptedException
{
throw new UnsupportedOperationException();
}
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 3b49914..7bb544b 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
@@ -58,7 +58,6 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_283985_SavePointTest;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_285008_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_289932_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_293283_Test;
-import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_294850_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_294859_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_296561_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_298561_Test;
@@ -226,7 +225,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_285008_Test.class);
testClasses.add(Bugzilla_289932_Test.class);
testClasses.add(Bugzilla_293283_Test.class);
- testClasses.add(Bugzilla_294850_Test.class);
testClasses.add(Bugzilla_294859_Test.class);
testClasses.add(Bugzilla_296561_Test.class);
testClasses.add(Bugzilla_298561_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
index 835781a..17babfa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
@@ -338,7 +338,7 @@ public class LockingManagerTest extends AbstractCDOTest
}
}
- public void testReadLockAndCommitFromDifferenceTransaction() throws Exception
+ public void testReadLockAndCommitFromDifferentTransaction() throws Exception
{
Company company = getModel1Factory().createCompany();
@@ -365,7 +365,7 @@ public class LockingManagerTest extends AbstractCDOTest
}
}
- public void testWriteLockAndCommitFromDifferenceTransaction() throws Exception
+ public void testWriteLockAndCommitFromDifferentTransaction() throws Exception
{
Company company = getModel1Factory().createCompany();
@@ -704,4 +704,60 @@ public class LockingManagerTest extends AbstractCDOTest
{
assertEquals(true, object.cdoWriteLock().tryLock(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS));
}
+
+ public void testReadLockStaleRevision() throws CommitException
+ {
+ testLockStaleRevision(LockType.READ);
+ }
+
+ public void testWriteLockStaleRevision() throws CommitException
+ {
+ testLockStaleRevision(LockType.WRITE);
+ }
+
+ private void testLockStaleRevision(LockType type) throws CommitException
+ {
+ CDOSession session = openSession();
+ session.options().setPassiveUpdateEnabled(false);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource("/res1");
+
+ Company company = getModel1Factory().createCompany();
+ company.setName("AAA");
+ res.getContents().add(company);
+ transaction.commit();
+
+ updateInOtherSession();
+
+ try
+ {
+ if (type == LockType.WRITE)
+ {
+ CDOUtil.getCDOObject(company).cdoWriteLock().lock();
+ }
+ else if (type == LockType.READ)
+ {
+ CDOUtil.getCDOObject(company).cdoReadLock().lock();
+ }
+ fail("Should have thrown IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+
+ session.close();
+ }
+
+ private void updateInOtherSession() throws CommitException
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource("/res1");
+
+ Company company = (Company)res.getContents().get(0);
+ company.setName("BBB");
+ transaction.commit();
+
+ session.close();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294850_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294850_Test.java
deleted file mode 100644
index 27c4b0c..0000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_294850_Test.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright (c) 2004 - 2010 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.CDOObject;
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-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.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.CommitException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.spi.cdo.AbstractObjectConflictResolver;
-
-import java.util.List;
-
-/**
- * Bug 294850 - Lock.lock() should invoke conflict resolver in case of conflicts - but doesn't
- *
- * @author Caspar De Groot
- */
-public class Bugzilla_294850_Test extends AbstractCDOTest
-{
- private static String RESOURCE_NAME = "/r1";
-
- public void testConflictResolverOnLock100() throws Exception
- {
- for (int i = 0; i < 100; i++)
- {
- testConflictResolverOnLock();
- }
- }
-
- public void testConflictResolverOnLock() throws Exception
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
-
- final TestResolver resolver = new TestResolver();
- tx.options().addConflictResolver(resolver);
-
- CDOResource r1 = tx.getOrCreateResource(RESOURCE_NAME);
-
- final Company company = Model1Factory.eINSTANCE.createCompany();
- r1.getContents().add(company);
- tx.commit();
-
- // Touch the company
- company.setName("aaa");
-
- // Touch in other session also
- doSecondSession();
-
- new PollingTimeOuter()
- {
- @Override
- protected boolean successful()
- {
- return resolver.gotCalled && CDOUtil.getCDOObject(company).cdoState() == CDOState.CONFLICT;
- }
- }.assertNoTimeOut();
-
- // Lock company to trigger a refresh
- CDOUtil.getCDOObject(company).cdoWriteLock().lock(DEFAULT_TIMEOUT);
-
- // Object should be in conflict state now
- assertSame(CDOState.CONFLICT, CDOUtil.getCDOObject(company).cdoState());
-
- // And therefore, resolver should have been called
- assertTrue(resolver.gotCalled);
-
- tx.close();
- session.close();
- }
-
- private void doSecondSession() throws CommitException
- {
- CDOSession session = openSession();
- CDOTransaction tx = session.openTransaction();
- CDOResource r1 = tx.getResource(RESOURCE_NAME);
- EList<EObject> contents = r1.getContents();
- Company c = (Company)contents.get(contents.size() - 1);
-
- // Touch the company
- c.setName("bbb");
-
- tx.commit();
- tx.close();
- session.close();
- }
-
- /**
- * @author Caspar De Groot
- */
- private static final class TestResolver extends AbstractObjectConflictResolver
- {
- public boolean gotCalled;
-
- @Override
- protected void resolveConflict(CDOObject conflict, CDORevision oldRemoteRevision, CDORevisionDelta localDelta,
- CDORevisionDelta remoteDelta, List<CDORevisionDelta> allRemoteDeltas)
- {
- gotCalled = true;
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
index 0b6080c..0d34480 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
@@ -543,16 +543,15 @@ public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionPr
}
}
- public RefreshSessionResult lockObjects(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, LockType lockType, long timeout)
- throws InterruptedException
+ public boolean lockObjects(List<InternalCDORevision> viewedRevisions, int viewID, CDOBranch viewedBranch,
+ LockType lockType, long timeout) throws InterruptedException
{
int attempt = 0;
for (;;)
{
try
{
- return delegate.lockObjects(lastUpdateTime, viewedRevisions, viewID, lockType, timeout);
+ return delegate.lockObjects(viewedRevisions, viewID, viewedBranch, lockType, timeout);
}
catch (Exception ex)
{
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 5fcc8d3..a14c0b9 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
@@ -18,15 +18,12 @@ 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.common.id.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.common.util.CDOException;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
@@ -67,12 +64,10 @@ import org.eclipse.emf.common.notify.impl.NotificationImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -80,6 +75,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -227,7 +223,7 @@ public class CDOViewImpl extends AbstractCDOView
try
{
- Map<CDOID, InternalCDORevision> revisions = new HashMap<CDOID, InternalCDORevision>();
+ List<InternalCDORevision> revisions = new LinkedList<InternalCDORevision>();
for (CDOObject object : objects)
{
if (!FSMUtil.isNew(object))
@@ -238,23 +234,12 @@ public class CDOViewImpl extends AbstractCDOView
revision = CDOStateMachine.INSTANCE.read((InternalCDOObject)object);
}
- revisions.put(revision.getID(), revision);
+ revisions.add(revision);
}
}
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions = new HashMap<CDOBranch, Map<CDOID, InternalCDORevision>>();
- viewedRevisions.put(getBranch(), revisions);
-
CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
- long lastUpdateTime = session.getLastUpdateTime();
- RefreshSessionResult result = sessionProtocol.lockObjects(lastUpdateTime, viewedRevisions, viewID, lockType,
- timeout);
-
- registerPackageUnits(result.getPackageUnits());
-
- InternalCDOView view = this;
- List<InternalCDOView> views = Collections.singletonList(view);
- session.processRefreshSessionResult(result, getBranch(), views, viewedRevisions);
+ sessionProtocol.lockObjects(revisions, viewID, getBranch(), lockType, timeout);
}
finally
{
@@ -263,15 +248,6 @@ public class CDOViewImpl extends AbstractCDOView
}
}
- private void registerPackageUnits(List<CDOPackageUnit> packageUnits)
- {
- InternalCDOPackageRegistry packageRegistry = session.getPackageRegistry();
- for (CDOPackageUnit newPackageUnit : packageUnits)
- {
- packageRegistry.putPackageUnit((InternalCDOPackageUnit)newPackageUnit);
- }
- }
-
/**
* @since 2.0
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
index bedcee5..9b0e541 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
@@ -121,11 +121,10 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
public boolean cancelQuery(int queryId);
/**
- * @since 3.0
+ * @since 4.0
*/
- public RefreshSessionResult lockObjects(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int viewID, LockType lockType, long timeout)
- throws InterruptedException;
+ public boolean lockObjects(List<InternalCDORevision> viewedRevisions, int viewID, CDOBranch viewedBranch,
+ LockType lockType, long timeout) throws InterruptedException;
/**
* @since 3.0