|
@@ -74,7 +74,13 @@ public class LoggingScheduledExecutorService extends ScheduledThreadPoolExecutor
|
74
|
74
|
super.afterExecute(r, t);
|
75
|
75
|
if (t == null && r instanceof Future<?>) {
|
76
|
76
|
try {
|
77
|
|
- ((Future<?>) r).get();
|
|
77
|
+ if (((Future<?>) r).isDone()) {
|
|
78
|
+ // If a periodic task completes successfully it is reset before this method
|
|
79
|
+ // is called, and get() will block indefinitely. If it is not scheduled to run
|
|
80
|
+ // again, or if it has thrown an exception and been stopped by the executor,
|
|
81
|
+ // then isDone() will return true and we can safely call get().
|
|
82
|
+ ((Future<?>) r).get();
|
|
83
|
+ }
|
78
|
84
|
} catch (ExecutionException ex) {
|
79
|
85
|
afterExecute.accept(r, ex);
|
80
|
86
|
} catch (InterruptedException ex) {
|