You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/06/17 21:32:50 UTC

svn commit: r785765 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java

Author: elecharny
Date: Wed Jun 17 19:32:48 2009
New Revision: 785765

URL: http://svn.apache.org/viewvc?rev=785765&view=rev
Log:
Fixed a problem in the CSN factory : we may have had produced incorrect incremental CSN

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java?rev=785765&r1=785764&r2=785765&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java Wed Jun 17 19:32:48 2009
@@ -56,17 +56,20 @@
      */
     public Csn newInstance()
     {
-        long newTimestamp = System.currentTimeMillis();
-        
-        // We will be able to generate 2 147 483 647 CSNs each 10 ms max
-        if ( lastTimestamp == newTimestamp )
+        synchronized ( changeCount )
         {
-            changeCount.incrementAndGet();
-        }
-        else
-        {
-            lastTimestamp = newTimestamp;
-            changeCount.set( 0 );
+            long newTimestamp = System.currentTimeMillis();
+            
+            // We will be able to generate 2 147 483 647 CSNs each 10 ms max
+            if ( lastTimestamp == newTimestamp )
+            {
+                changeCount.incrementAndGet();
+            }
+            else
+            {
+                lastTimestamp = newTimestamp;
+                changeCount.set( 0 );
+            }
         }
 
         return new Csn( lastTimestamp, changeCount.get(), replicaId, 0 );