cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r535352 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne: CayenneContext.java access/DataContext.java
Date Fri, 04 May 2007 18:59:33 GMT
Author: aadamchik
Date: Fri May  4 11:59:19 2007
New Revision: 535352

URL: http://svn.apache.org/viewvc?view=rev&rev=535352
Log:
CAY-786 - Race condition in DataContext.localObject()
applying fix to trunk... will be testing it in a live app before applying to the stable branches

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.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=535352&r1=535351&r2=535352
==============================================================================
--- 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
Fri May  4 11:59:19 2007
@@ -403,12 +403,15 @@
             // breaking encapsulation of the DataChannel to detect where in the hierarchy
             // this context is.
 
-            Persistent localObject = (Persistent) descriptor.createObject();
+            Persistent localObject;
+            synchronized (getGraphManager()) {
+                localObject = (Persistent) descriptor.createObject();
 
-            localObject.setObjectContext(this);
-            localObject.setObjectId(id);
+                localObject.setObjectContext(this);
+                localObject.setObjectId(id);
 
-            getGraphManager().registerNode(id, localObject);
+                getGraphManager().registerNode(id, localObject);
+            }
 
             if (prototype != null) {
                 localObject.setPersistenceState(PersistenceState.COMMITTED);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?view=diff&rev=535352&r1=535351&r2=535352
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
Fri May  4 11:59:19 2007
@@ -1694,12 +1694,16 @@
         // create and merge into a new object
         else {
 
-            Persistent localObject = (Persistent) descriptor.createObject();
+            Persistent localObject;
 
-            localObject.setObjectContext(this);
-            localObject.setObjectId(id);
+            synchronized (getGraphManager()) {
+                localObject = (Persistent) descriptor.createObject();
 
-            getGraphManager().registerNode(id, localObject);
+                localObject.setObjectContext(this);
+                localObject.setObjectId(id);
+
+                getGraphManager().registerNode(id, localObject);
+            }
 
             if (prototype != null
                     && ((Persistent) prototype).getPersistenceState() != PersistenceState.HOLLOW)
{



Mime
View raw message