jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1377686 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
Date Mon, 27 Aug 2012 14:02:57 GMT
Author: mduerig
Date: Mon Aug 27 14:02:56 2012
New Revision: 1377686

URL: http://svn.apache.org/viewvc?rev=1377686&view=rev
Log:
OAK-279: ChangeProcessor getting stuck while shutdown
fixing the immediate issues at hand. a potential deadlock remains

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java?rev=1377686&r1=1377685&r2=1377686&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/observation/ChangeProcessor.java
Mon Aug 27 14:02:56 2012
@@ -65,19 +65,25 @@ class ChangeProcessor implements Runnabl
 
     /**
      * Stop this change processor if running. After returning from this methods no further
-     * events will be delivered. This method has no effect if the change processor is not
running.
-     * A change processor is running while execution is inside its {@code run()} method.
+     * events will be delivered.
      */
     public synchronized void stop() {
-        if (running) {
-            try {
-                stopping = true;
-                future.cancel(true);
+        if (future == null) {
+            throw new IllegalStateException("Change processor not started");
+        }
+
+        try {
+            stopping = true;
+            future.cancel(true);
+            if (running) {
                 stopped.await();
             }
-            catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-            }
+        }
+        catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }
+        finally {
+            future = null;
         }
     }
 
@@ -96,13 +102,18 @@ class ChangeProcessor implements Runnabl
     @Override
     public void run() {
         running = true;
-        EventGeneratingNodeStateDiff diff = new EventGeneratingNodeStateDiff();
-        changeExtractor.getChanges(diff);
-        if (!stopping) {
-            diff.sendEvents();
+        try{
+            EventGeneratingNodeStateDiff diff = new EventGeneratingNodeStateDiff();
+            changeExtractor.getChanges(diff);
+            if (!stopping) {
+                diff.sendEvents();
+            }
+        } finally{
+            if (stopping) {
+                stopped.countDown();
+            }
+            running = false;
         }
-        stopped.countDown();
-        running = false;
     }
 
     //------------------------------------------------------------< private >---



Mime
View raw message