cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r535488 - /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
Date Sat, 05 May 2007 10:00:38 GMT
Author: aadamchik
Date: Sat May  5 03:00:37 2007
New Revision: 535488

URL: http://svn.apache.org/viewvc?view=rev&rev=535488
Log:
CAY-786 - Race condition in DataContext.localObject()
found a similar race condition in CayenneContext.createFault

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java?view=diff&rev=535488&r1=535487&r2=535488
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
Sat May  5 03:00:37 2007
@@ -484,13 +484,16 @@
         ClassDescriptor descriptor = getEntityResolver().getClassDescriptor(
                 id.getEntityName());
 
-        Persistent object = (Persistent) descriptor.createObject();
+        Persistent object;
+        synchronized (graphManager) {
+            object = (Persistent) descriptor.createObject();
 
-        object.setPersistenceState(PersistenceState.HOLLOW);
-        object.setObjectContext(this);
-        object.setObjectId(id);
+            object.setPersistenceState(PersistenceState.HOLLOW);
+            object.setObjectContext(this);
+            object.setObjectId(id);
 
-        graphManager.registerNode(id, object);
+            graphManager.registerNode(id, object);
+        }
 
         return object;
     }



Mime
View raw message