jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1022946 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Date Fri, 15 Oct 2010 14:31:26 GMT
Author: thomasm
Date: Fri Oct 15 14:31:26 2010
New Revision: 1022946

URL: http://svn.apache.org/viewvc?rev=1022946&view=rev
Log:
JCR-2786 Cluster sync not always done when calling session.refresh(..)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=1022946&r1=1022945&r2=1022946&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Fri Oct 15 14:31:26 2010
@@ -20,6 +20,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jcr.RepositoryException;
 
@@ -127,7 +128,7 @@ public class ClusterNode implements Runn
      * @since Apache Jackrabbit 1.6
      * @see <a href="https://issues.apache.org/jira/browse/JCR-1753">JCR-1753</a>
      */
-    private volatile int syncCount;
+    private AtomicInteger syncCount = new AtomicInteger();
 
     /**
      * Status flag, one of {@link #NONE}, {@link #STARTED} or {@link #STOPPED}.
@@ -287,7 +288,7 @@ public class ClusterNode implements Runn
      * @throws ClusterException if an error occurs
      */
     public void sync() throws ClusterException {
-        int count = syncCount;
+        int count = syncCount.get();
 
         try {
             syncLock.acquire();
@@ -299,9 +300,9 @@ public class ClusterNode implements Runn
         try {
             // JCR-1753: Only synchronize if no other thread already did so
             // while we were waiting to acquire the syncLock.
-            if (count == syncCount) {
+            if (count == syncCount.get()) {
+                syncCount.incrementAndGet();
                 journal.sync();
-                syncCount++;
             }
         } catch (JournalException e) {
             throw new ClusterException(e.getMessage(), e.getCause());



Mime
View raw message