|
7 | 7 | import java.util.Iterator; |
8 | 8 | import java.util.List; |
9 | 9 | import java.util.concurrent.BlockingQueue; |
| 10 | +import java.util.concurrent.CancellationException; |
10 | 11 | import java.util.concurrent.ExecutionException; |
11 | 12 | import java.util.concurrent.Future; |
12 | 13 | import java.util.concurrent.LinkedBlockingQueue; |
@@ -107,28 +108,25 @@ public void queueObjects(List<T> objects) { |
107 | 108 | } |
108 | 109 |
|
109 | 110 | public void waitForPendingFutures() { |
110 | | - |
111 | 111 | Log.d(Log.TAG_BATCHER, "%s: waitForPendingFutures", this); |
112 | | - |
113 | 112 | try { |
114 | | - |
115 | 113 | while (!pendingFutures.isEmpty()) { |
116 | 114 | Future future = pendingFutures.take(); |
117 | 115 | try { |
118 | 116 | Log.d(Log.TAG_BATCHER, "calling future.get() on %s", future); |
119 | 117 | future.get(); |
120 | 118 | Log.d(Log.TAG_BATCHER, "done calling future.get() on %s", future); |
121 | | - } catch (InterruptedException e) { |
122 | | - e.printStackTrace(); |
| 119 | + } catch (CancellationException e) { |
| 120 | + Log.i(Log.TAG_BATCHER, "Task was canceled: " + e.getMessage()); |
123 | 121 | } catch (ExecutionException e) { |
124 | | - e.printStackTrace(); |
| 122 | + Log.e(Log.TAG_BATCHER, "ERROR: Task aborted: " + e.getMessage()); |
| 123 | + } catch (InterruptedException e) { |
| 124 | + Log.w(Log.TAG_BATCHER, e.getMessage()); |
125 | 125 | } |
126 | 126 | } |
127 | | - |
128 | 127 | } catch (Exception e) { |
129 | 128 | Log.e(Log.TAG_BATCHER, "Exception waiting for pending futures: %s", e); |
130 | 129 | } |
131 | | - |
132 | 130 | Log.d(Log.TAG_BATCHER, "%s: /waitForPendingFutures", this); |
133 | 131 | } |
134 | 132 |
|
|
0 commit comments