Author: aadamchik
Date: Sat Dec 28 10:39:45 2013
New Revision: 1553805

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

porting from trunk

Modified:
    
cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java

Modified: 
cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java?rev=1553805&r1=1553804&r2=1553805&view=diff
==============================================================================
--- 
cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
 (original)
+++ 
cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
 Sat Dec 28 10:39:45 2013
@@ -587,11 +587,19 @@ public class ObjRelationship extends Rel
        /**
         * Loads path from "deferredPath" variable (if specified)
         */
-       synchronized void refreshFromDeferredPath() {
-               if (deferredPath != null) {
-                       refreshFromPath(deferredPath, true);
-                       deferredPath = null;
-               }
+       void refreshFromDeferredPath() {
+        if (deferredPath != null) {
+            
+            synchronized(this) {
+                
+                // check if another thread just 
+                // loaded path from deferredPath
+                if (deferredPath != null){
+                    refreshFromPath(deferredPath, true);
+                    deferredPath = null;
+                }
+            }
+        }
        }
 
        /**
@@ -637,7 +645,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();
@@ -671,7 +678,6 @@ public class ObjRelationship extends Rel
 
                        recalculateToManyValue();
                        recalculateReadOnlyValue();
-               }
        }
 
        /**


Reply via email to