Author: cziegeler
Date: Wed Jan 26 17:37:02 2011
New Revision: 1063803

URL: http://svn.apache.org/viewvc?rev=1063803&view=rev
Log:
SLING-1955 : Event Support Unit Tests stall in full trunk build

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

Modified: 
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java?rev=1063803&r1=1063802&r2=1063803&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java
 (original)
+++ 
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/AbstractJobQueue.java
 Wed Jan 26 17:37:02 2011
@@ -406,28 +406,36 @@ public abstract class AbstractJobQueue
     }
 
     /**
-     * Execute the qeue
+     * Check if the queue is suspended and go into suspend mode
+     */
+    private void checkSuspended() {
+        synchronized ( this.suspendLock ) {
+            while ( this.suspendedSince != -1 ) {
+                try {
+                    this.suspendLock.wait(MAX_SUSPEND_TIME);
+                } catch (final InterruptedException ignore) {
+                    this.ignoreException(ignore);
+                }
+                if ( System.currentTimeMillis() > this.suspendedSince + 
MAX_SUSPEND_TIME ) {
+                    this.resume();
+                }
+            }
+        }
+    }
+
+    /**
+     * Execute the queue
      */
     private void runJobQueue() {
         JobEvent info = null;
         while ( this.running ) {
-            synchronized ( this.suspendLock ) {
-                while ( this.suspendedSince != -1 ) {
-                    try {
-                        this.suspendLock.wait(MAX_SUSPEND_TIME);
-                    } catch (final InterruptedException ignore) {
-                        this.ignoreException(ignore);
-                    }
-                    if ( System.currentTimeMillis() > this.suspendedSince + 
MAX_SUSPEND_TIME ) {
-                        this.resume();
-                    }
-                }
-            }
             if ( info == null ) {
                 // so let's wait/get the next job from the queue
                 info = this.take();
             }
 
+            checkSuspended();
+
             if ( info != null && this.running ) {
                 info = this.start(info);
             }


Reply via email to