Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2009-09-25 00:11:53 +0000
committerSimon McDuff2009-09-25 00:11:53 +0000
commitecd83f68091e1f2f18881c14f58ccb6059f70232 (patch)
tree0142f2c265d97e5c1c8a11fe6c2b8f6ed4322ef7 /plugins/org.eclipse.emf.cdo
parent9bb4ead982787c3c57433bcb9f65880cc079029a (diff)
downloadcdo-ecd83f68091e1f2f18881c14f58ccb6059f70232.tar.gz
cdo-ecd83f68091e1f2f18881c14f58ccb6059f70232.tar.xz
cdo-ecd83f68091e1f2f18881c14f58ccb6059f70232.zip
[289584] Deadlock in CDOView
https://bugs.eclipse.org/bugs/show_bug.cgi?id=289584
Diffstat (limited to 'plugins/org.eclipse.emf.cdo')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java73
1 files changed, 44 insertions, 29 deletions
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 9051c2dafb..88696bcf74 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
@@ -713,49 +713,64 @@ public class CDOViewImpl extends Lifecycle implements InternalCDOView
{
return null;
}
-
- synchronized (objects)
+ // Since getObject could trigger a read (ONLY when we load a resource) we NEED to make sure the state lock is
+ // active.
+ // Always use in the following order
+ // 1- getStateLock().lock();
+ // 2- synchronized(objects)
+ // DO NOT inverse them otherwise deadlock could occured.
+
+ ReentrantLock stateLock = getStateLock();
+ stateLock.lock();
+ try
{
- if (id.equals(lastLookupID))
- {
- return lastLookupObject;
- }
-
- // Needed for recursive call to getObject. (from createObject/cleanObject/getResource/getObject)
- InternalCDOObject localLookupObject = objects.get(id);
- if (localLookupObject == null)
+ synchronized (objects)
{
- if (id.isMeta())
+ if (id.equals(lastLookupID))
{
- localLookupObject = createMetaObject((CDOIDMeta)id);
+ return lastLookupObject;
}
- else
+
+ // Needed for recursive call to getObject. (from createObject/cleanObject/getResource/getObject)
+ InternalCDOObject localLookupObject = objects.get(id);
+ if (localLookupObject == null)
{
- if (loadOnDemand)
+ if (id.isMeta())
+ {
+ localLookupObject = createMetaObject((CDOIDMeta)id);
+ }
+ else
{
- if (id.isTemporary())
+ if (loadOnDemand)
{
- throw new ObjectNotFoundException(id);
- }
+ if (id.isTemporary())
+ {
+ throw new ObjectNotFoundException(id);
+ }
- localLookupObject = createObject(id);
+ localLookupObject = createObject(id);
+ }
+ else
+ {
+ return null;
+ }
}
- else
+
+ // CDOResource have a special way to register to the view.
+ if (!CDOModelUtil.isResource(localLookupObject.eClass()))
{
- return null;
+ registerObject(localLookupObject);
}
}
- // CDOResource have a special way to register to the view.
- if (!CDOModelUtil.isResource(localLookupObject.eClass()))
- {
- registerObject(localLookupObject);
- }
+ lastLookupID = id;
+ lastLookupObject = localLookupObject;
+ return lastLookupObject;
}
-
- lastLookupID = id;
- lastLookupObject = localLookupObject;
- return lastLookupObject;
+ }
+ finally
+ {
+ stateLock.unlock();
}
}

Back to the top