roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ko...@apache.org
Subject svn commit: r1708081 - in /roller/trunk/app/src/main/java/org/apache/roller/weblogger/business: HitCountQueue.java runnable/ContinuousWorkerThread.java
Date Mon, 12 Oct 2015 10:38:49 GMT
Author: kohei
Date: Mon Oct 12 10:38:48 2015
New Revision: 1708081

URL: http://svn.apache.org/viewvc?rev=1708081&view=rev
Log:
Fix shutdown procedure of ContinuousWorkerThread (it won't stop if interrupt() has been invoked
during the thread is running)

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java?rev=1708081&r1=1708080&r2=1708081&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/HitCountQueue.java
Mon Oct 12 10:38:48 2015
@@ -114,6 +114,12 @@ public final class HitCountQueue {
         if(this.worker != null) {
             log.info("stopping worker "+this.worker.getName());
             worker.interrupt();
+            try {
+                // wait 10 seconds for graceful shutdown
+                worker.join(10 * 1000);
+            } catch (InterruptedException e) {
+                log.debug("interrupted", e);
+            }
         }
         
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java?rev=1708081&r1=1708080&r2=1708081&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java
Mon Oct 12 10:38:48 2015
@@ -60,8 +60,8 @@ public class ContinuousWorkerThread exte
         
         mLogger.info(this.id+" Started.");
         
-        // run forever
-        while(true) {
+        // run till interrupted
+        while (!Thread.currentThread().isInterrupted()) {
             
             // execute our job
             super.run();
@@ -75,6 +75,8 @@ public class ContinuousWorkerThread exte
                 break;
             }
         }
+
+        mLogger.info(this.id+" Done.");
     }
-    
+
 }



Mime
View raw message