Browse Source

Merge pull request #546 from greboid/master

Ignore CancellationException in the LoggingExecutorServices
pull/547/head
Chris Smith 9 years ago
parent
commit
06d717567a

+ 3
- 2
src/com/dmdirc/util/LoggingExecutorService.java View File

@@ -29,6 +29,7 @@ import com.dmdirc.logger.ErrorLevel;
29 29
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
30 30
 
31 31
 import java.util.concurrent.ArrayBlockingQueue;
32
+import java.util.concurrent.CancellationException;
32 33
 import java.util.concurrent.ExecutionException;
33 34
 import java.util.concurrent.Future;
34 35
 import java.util.concurrent.ThreadPoolExecutor;
@@ -80,10 +81,10 @@ public class LoggingExecutorService extends ThreadPoolExecutor {
80 81
         if (t == null && r instanceof Future<?>) {
81 82
             try {
82 83
             ((Future<?>) r).get();
84
+            } catch (CancellationException | InterruptedException ex) {
85
+                //Ignore
83 86
             } catch (ExecutionException ex) {
84 87
                 afterExecute.accept(r, ex);
85
-            } catch (InterruptedException ex) {
86
-                //Ignore
87 88
             }
88 89
         }
89 90
         if (t != null) {

+ 3
- 2
src/com/dmdirc/util/LoggingScheduledExecutorService.java View File

@@ -28,6 +28,7 @@ import com.dmdirc.logger.ErrorLevel;
28 28
 
29 29
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
30 30
 
31
+import java.util.concurrent.CancellationException;
31 32
 import java.util.concurrent.ExecutionException;
32 33
 import java.util.concurrent.Future;
33 34
 import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -81,10 +82,10 @@ public class LoggingScheduledExecutorService extends ScheduledThreadPoolExecutor
81 82
                     // then isDone() will return true and we can safely call get().
82 83
                     ((Future<?>) r).get();
83 84
                 }
85
+            } catch (CancellationException | InterruptedException ex) {
86
+                //Ignore
84 87
             } catch (ExecutionException ex) {
85 88
                 afterExecute.accept(r, ex);
86
-            } catch (InterruptedException ex) {
87
-                //Ignore
88 89
             }
89 90
         }
90 91
         if (t != null) {

Loading…
Cancel
Save