sijie closed pull request #1702: Issue #1700: fixed: TimedRunnable does not 
anticipate exception from wrapped runnable
URL: https://github.com/apache/bookkeeper/pull/1702
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
 
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
index 520787b383..ab62a687e1 100644
--- 
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
+++ 
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/OrderedExecutor.java
@@ -187,12 +187,15 @@ public T build() {
         public void run() {
             
taskPendingStats.registerSuccessfulEvent(MathUtils.elapsedNanos(initNanos), 
TimeUnit.NANOSECONDS);
             long startNanos = MathUtils.nowInNano();
-            this.runnable.run();
-            long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos);
-            taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, 
TimeUnit.MICROSECONDS);
-            if (elapsedMicroSec >= warnTimeMicroSec) {
-                log.warn("Runnable {}:{} took too long {} micros to execute.", 
runnable, runnable.getClass(),
-                        elapsedMicroSec);
+            try {
+                this.runnable.run();
+            } finally {
+                long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos);
+                taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, 
TimeUnit.MICROSECONDS);
+                if (elapsedMicroSec >= warnTimeMicroSec) {
+                    log.warn("Runnable {}:{} took too long {} micros to 
execute.", runnable, runnable.getClass(),
+                            elapsedMicroSec);
+                }
             }
         }
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to