Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2019-02-02 07:56:42 +0000
committerEike Stepper2019-02-02 07:56:42 +0000
commit86157bcc07f74557fee87e30a7b230fada8f4cd8 (patch)
treeb1cb53be85e168dc6fbab3b463371086f0806e9a /plugins
parent7217380110c2353c2a6df073614f3a046135952f (diff)
downloadcdo-86157bcc07f74557fee87e30a7b230fada8f4cd8.tar.gz
cdo-86157bcc07f74557fee87e30a7b230fada8f4cd8.tar.xz
cdo-86157bcc07f74557fee87e30a7b230fada8f4cd8.zip
[544057] CDOObject.cdoReadLock().isLockedByOthers() returns true if lock is held by myself
https://bugs.eclipse.org/bugs/show_bug.cgi?id=544057
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java23
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUpdatable.java6
3 files changed, 27 insertions, 9 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
index d340ca8cf3..bd6a11d9e8 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
@@ -120,12 +120,7 @@ public class CDOLockStateImpl implements InternalCDOLockState
return false;
}
- if (!others)
- {
- return readLockOwners.contains(by);
- }
-
- return true;
+ return readLockOwners.contains(by) ^ others;
}
private boolean isWriteLocked(CDOLockOwner by, boolean others)
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 a7845661d6..493f7cf67e 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
@@ -867,6 +867,29 @@ public class LockingManagerTest extends AbstractLockingTest
assertEquals(false, repo.getLockingManager().hasLock(LockType.READ, view, cdoCompany.cdoID()));
}
+ public void testReadLockedByOthers() throws Exception
+ {
+ Company company = getModel1Factory().createCompany();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource(getResourcePath("/res1"));
+ res.getContents().add(company);
+ transaction.commit();
+ assertFalse(CDOUtil.getCDOObject(company).cdoReadLock().isLockedByOthers());
+
+ transaction.lockObjects(CDOUtil.getCDOObjects(company), LockType.READ, DEFAULT_TIMEOUT);
+ assertReadLock(true, company);
+ assertWriteLock(false, company);
+ assertFalse(CDOUtil.getCDOObject(company).cdoReadLock().isLockedByOthers());
+
+ CDOView view = session.openView();
+ Company viewCompany = view.getObject(company);
+ assertReadLock(false, viewCompany);
+ assertWriteLock(false, viewCompany);
+ assertTrue(CDOUtil.getCDOObject(viewCompany).cdoReadLock().isLockedByOthers());
+ }
+
public void testBugzilla_270345() throws Exception
{
Company company1 = getModel1Factory().createCompany();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUpdatable.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUpdatable.java
index c076f8512c..05a3b62973 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUpdatable.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUpdatable.java
@@ -32,15 +32,15 @@ public interface CDOUpdatable
public long getLastUpdateTime();
/**
- * Blocks the calling thread until a commit operation with the given time stamp (or higher) has occured.
+ * Blocks the calling thread until a commit operation with the given time stamp (or higher) has occurred.
*/
public void waitForUpdate(long updateTime);
/**
- * Blocks the calling thread until a commit operation with the given time stamp (or higher) has occured or the given
+ * Blocks the calling thread until a commit operation with the given time stamp (or higher) has occurred or the given
* timeout has expired.
*
- * @return <code>true</code> if the specified commit operation has occured within the given timeout period,
+ * @return <code>true</code> if the specified commit operation has occurred within the given timeout period,
* <code>false</code> otherwise.
*/
public boolean waitForUpdate(long updateTime, long timeoutMillis);

Back to the top