incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1040146 - /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
Date Mon, 29 Nov 2010 15:19:49 GMT
Author: cziegeler
Date: Mon Nov 29 15:19:49 2010
New Revision: 1040146

URL: http://svn.apache.org/viewvc?rev=1040146&view=rev
Log:
Fix potential sync problem in ordered queue: a job might be finished before the queue starts
waiting

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java?rev=1040146&r1=1040145&r2=1040146&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/OrderedJobQueue.java
Mon Nov 29 15:19:49 2010
@@ -67,8 +67,21 @@ public final class OrderedJobQueue exten
         JobEvent rescheduleInfo = null;
 
         // if we are ordered we simply wait for the finish
-        if ( this.executeJob(processInfo) ) {
-            rescheduleInfo = this.waitForFinish();
+        synchronized ( this.syncLock ) {
+            if ( this.executeJob(processInfo) ) {
+                this.isWaiting = true;
+                this.logger.debug("Job queue {} is waiting for finish.", this.queueName);
+                while ( this.isWaiting ) {
+                    try {
+                        this.syncLock.wait();
+                    } catch (InterruptedException e) {
+                        this.ignoreException(e);
+                    }
+                }
+                this.logger.debug("Job queue {} is continuing.", this.queueName);
+                rescheduleInfo = this.jobEvent;
+                this.jobEvent = null;
+            }
         }
         return rescheduleInfo;
     }
@@ -94,28 +107,6 @@ public final class OrderedJobQueue exten
         super.resume();
     }
 
-    /**
-     * Wait for the job to be finished.
-     * This is called if the queue is ordered.
-     */
-    private JobEvent waitForFinish() {
-        synchronized ( this.syncLock ) {
-            this.isWaiting = true;
-            this.logger.debug("Job queue {} is waiting for finish.", this.queueName);
-            while ( this.isWaiting ) {
-                try {
-                    this.syncLock.wait();
-                } catch (InterruptedException e) {
-                    this.ignoreException(e);
-                }
-            }
-            this.logger.debug("Job queue {} is continuing.", this.queueName);
-            final JobEvent object = this.jobEvent;
-            this.jobEvent = null;
-            return object;
-        }
-    }
-
     @Override
     protected void put(final JobEvent event) {
         try {



Mime
View raw message