You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2010/08/23 13:41:05 UTC

svn commit: r988085 - in /cayenne/main/branches/STABLE-3.0: docs/doc/src/main/resources/RELEASE-NOTES.txt framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/DataRow.java

Author: aadamchik
Date: Mon Aug 23 11:41:04 2010
New Revision: 988085

URL: http://svn.apache.org/viewvc?rev=988085&view=rev
Log:
CAY-1473 Ensure DataRow version increment is atomic

Modified:
    cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/DataRow.java

Modified: cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=988085&r1=988084&r2=988085&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt Mon Aug 23 11:41:04 2010
@@ -26,6 +26,7 @@ CAY-1458 Document Vertical Inheritance
 CAY-1467 Shut down EventManager in WebApplicationContextFilter.destroy()
 CAY-1468 Commit performance degradation
 CAY-1471 Create a source cayenne assembly
+CAY-1473 Ensure DataRow version increment is atomic
 
 ----------------------------------
 Release: 3.0 (final) 

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/DataRow.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/DataRow.java?rev=988085&r1=988084&r2=988085&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/DataRow.java (original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/DataRow.java Mon Aug 23 11:41:04 2010
@@ -22,6 +22,7 @@ package org.apache.cayenne;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -39,13 +40,11 @@ import org.apache.cayenne.util.Util;
  */
 public class DataRow extends HashMap<String, Object> {
 
-    // "volatile" is supposed to ensure consistency in read and increment operations;
-    // is this universally true?
-
     // make sure the starting value is different from DataObject default version value
-    private static volatile long currentVersion = DataObject.DEFAULT_VERSION + 1;
+    private static AtomicLong currentVersion = new AtomicLong(
+            DataObject.DEFAULT_VERSION + 1);
 
-    protected long version = currentVersion++;
+    protected long version = currentVersion.getAndIncrement();
     protected long replacesVersion = DataObject.DEFAULT_VERSION;
 
     /**