svn commit: r1371863 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1371863 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java

adrianc
Author: adrianc
Date: Sat Aug 11 03:39:03 2012
New Revision: 1371863

URL: http://svn.apache.org/viewvc?rev=1371863&view=rev
Log:
Changed JobPoller shutdown behavior - stop threads immediately and dequeue queued jobs.

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java?rev=1371863&r1=1371862&r2=1371863&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java Sat Aug 11 03:39:03 2012
@@ -241,23 +241,14 @@ public final class JobPoller implements
      */
     void stop() {
         Debug.logInfo("Shutting down thread pool for JobPoller " + this.name, module);
-        this.executor.shutdown();
-        try {
-            // Wait 60 seconds for existing tasks to terminate
-            if (!this.executor.awaitTermination(60, TimeUnit.SECONDS)) {
-                // abrupt shutdown (cancel currently executing tasks)
-                Debug.logInfo("Attempting abrupt shut down of thread pool for JobPoller " + this.name, module);
-                this.executor.shutdownNow();
-                // Wait 60 seconds for tasks to respond to being cancelled
-                if (!this.executor.awaitTermination(60, TimeUnit.SECONDS)) {
-                    Debug.logWarning("Unable to shutdown the thread pool for JobPoller " + this.name, module);
-                }
+        List<Runnable> queuedJobs = this.executor.shutdownNow();
+        for (Runnable task : queuedJobs) {
+            try {
+                Job queuedJob = (Job) task;
+                queuedJob.deQueue();
+            } catch (Exception e) {
+                Debug.logWarning(e, module);
             }
-        } catch (InterruptedException ie) {
-            // re cancel if current thread was also interrupted
-            this.executor.shutdownNow();
-            // preserve interrupt status
-            Thread.currentThread().interrupt();
         }
         Debug.logInfo("Shutdown completed of thread pool for JobPoller " + this.name, module);
     }