jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1518906 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeDispatcher.java
Date Fri, 30 Aug 2013 07:59:22 GMT
Author: mduerig
Date: Fri Aug 30 07:59:22 2013
New Revision: 1518906

URL: http://svn.apache.org/r1518906
Log:
OAK-959: Deadlock between ChangeDispatcher and SegmentNodeStoreService
Move getRoot call out of the lock to avoid deadlock between NodeStore and ChangeDispatcher

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeDispatcher.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeDispatcher.java?rev=1518906&r1=1518905&r2=1518906&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeDispatcher.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeDispatcher.java
Fri Aug 30 07:59:22 2013
@@ -24,8 +24,6 @@ import static org.apache.jackrabbit.oak.
 
 import java.util.Queue;
 import java.util.Set;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
@@ -54,7 +52,6 @@ import org.apache.jackrabbit.oak.spi.sta
 public class ChangeDispatcher {
     private final NodeStore store;
     private final Set<Listener> listeners = Sets.newHashSet();
-    private final Lock changeLock = new ReentrantLock();
 
     private NodeState previousRoot;
 
@@ -94,15 +91,10 @@ public class ChangeDispatcher {
         return listener;
     }
 
-    private void contentChanged(@Nonnull NodeState before, @Nonnull NodeState after,
+    private synchronized void contentChanged(@Nonnull NodeState before, @Nonnull NodeState
after,
             ContentSession contentSession) {
-        changeLock.lock();
-        try {
-            externalChange(checkNotNull(before));
-            internalChange(checkNotNull(after), contentSession);
-        } finally {
-            changeLock.unlock();
-        }
+        externalChange(checkNotNull(before));
+        internalChange(checkNotNull(after), contentSession);
     }
 
     private void externalChange(NodeState root) {
@@ -118,12 +110,9 @@ public class ChangeDispatcher {
     }
 
     private void externalChange() {
-        if (changeLock.tryLock()) {
-            try {
-                externalChange(store.getRoot());
-            } finally {
-                changeLock.unlock();
-            }
+        NodeState root = store.getRoot();
+        synchronized (this) {
+            externalChange(root);
         }
     }
 



Mime
View raw message