Просмотр исходного кода

Merge pull request #545 from csmith/master

Fix LSES blocking after a task is executed.
pull/546/head
Greg Holmes 9 лет назад
Родитель
Сommit
2738fddd62
1 измененных файлов: 7 добавлений и 1 удалений
  1. 7
    1
      src/com/dmdirc/util/LoggingScheduledExecutorService.java

+ 7
- 1
src/com/dmdirc/util/LoggingScheduledExecutorService.java Просмотреть файл

@@ -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) {

Загрузка…
Отмена
Сохранить