Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Roldan Betancort2009-12-31 12:17:49 +0000
committerVictor Roldan Betancort2009-12-31 12:17:49 +0000
commit108b8e1fb06df8766d59c74884b4dfe6034d2637 (patch)
tree02ab1632ea48e01eb40a143a3ea656d202996f7b
parente965454176c2d048d73db13aaa39f07fa055960d (diff)
downloadcdo-108b8e1fb06df8766d59c74884b4dfe6034d2637.tar.gz
cdo-108b8e1fb06df8766d59c74884b4dfe6034d2637.tar.xz
cdo-108b8e1fb06df8766d59c74884b4dfe6034d2637.zip
Bug 290484: Deadlock in CDOView
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java71
1 files changed, 43 insertions, 28 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 399ba26a5f..2fb932a1db 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
@@ -706,48 +706,63 @@ 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.
+ getStateLock().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
+ {
+ getStateLock().unlock();
}
}

Back to the top