Author: aadamchik
Date: Sat Dec 28 10:31:33 2013
New Revision: 1553802

URL: http://svn.apache.org/r1553802
Log:
CAY-1868 Select contention with multiple contexts

patch by Oleg Artyukevich

Modified:
    
cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/map/ObjRelationship.java

Modified: 
cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/map/ObjRelationship.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/map/ObjRelationship.java?rev=1553802&r1=1553801&r2=1553802&view=diff
==============================================================================
--- 
cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/map/ObjRelationship.java
 (original)
+++ 
cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/map/ObjRelationship.java
 Sat Dec 28 10:31:33 2013
@@ -575,8 +575,16 @@ public class ObjRelationship extends Rel
      */
     synchronized void refreshFromDeferredPath() {
         if (deferredPath != null) {
-            refreshFromPath(deferredPath, true);
-            deferredPath = null;
+            
+            synchronized(this) {
+                
+                // check if another thread just 
+                // loaded path from deferredPath
+                if (deferredPath != null){
+                    refreshFromPath(deferredPath, true);
+                    deferredPath = null;
+                }
+            }
         }
     }
 
@@ -622,8 +630,6 @@ public class ObjRelationship extends Rel
      * Rebuild a list of relationships if String relationshipPath has changed.
      */
     final void refreshFromPath(String dbRelationshipPath, boolean 
stripInvalid) {
-        synchronized (this) {
-
             // remove existing relationships
             dbRelationships.clear();
 
@@ -652,7 +658,6 @@ public class ObjRelationship extends Rel
 
             recalculateToManyValue();
             recalculateReadOnlyValue();
-        }
     }
 
     /**


Reply via email to