174 |
|
t.join(); |
175 |
|
assertTrue(task.isDone()); |
176 |
|
assertTrue(task.isCancelled()); |
177 |
< |
} catch (InterruptedException e){ |
177 |
> |
} catch (InterruptedException e) { |
178 |
|
unexpectedException(); |
179 |
|
} |
180 |
|
} |
203 |
|
t.join(); |
204 |
|
assertTrue(task.isDone()); |
205 |
|
assertTrue(task.isCancelled()); |
206 |
< |
} catch (InterruptedException e){ |
206 |
> |
} catch (InterruptedException e) { |
207 |
|
unexpectedException(); |
208 |
|
} |
209 |
|
} |
216 |
|
public Object call() { |
217 |
|
try { |
218 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
219 |
< |
} catch (InterruptedException e){ |
219 |
> |
} catch (InterruptedException e) { |
220 |
|
threadUnexpectedException(); |
221 |
|
} |
222 |
|
return Boolean.TRUE; |
226 |
|
public void run() { |
227 |
|
try { |
228 |
|
ft.get(); |
229 |
< |
} catch (Exception e){ |
229 |
> |
} catch (Exception e) { |
230 |
|
threadUnexpectedException(); |
231 |
|
} |
232 |
|
} |
240 |
|
t.join(); |
241 |
|
assertTrue(ft.isDone()); |
242 |
|
assertFalse(ft.isCancelled()); |
243 |
< |
} catch (InterruptedException e){ |
243 |
> |
} catch (InterruptedException e) { |
244 |
|
unexpectedException(); |
245 |
|
|
246 |
|
} |
254 |
|
public Object call() { |
255 |
|
try { |
256 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
257 |
< |
} catch (InterruptedException e){ |
257 |
> |
} catch (InterruptedException e) { |
258 |
|
threadUnexpectedException(); |
259 |
|
} |
260 |
|
return Boolean.TRUE; |
265 |
|
try { |
266 |
|
ft.get(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
267 |
|
} catch (TimeoutException success) { |
268 |
< |
} catch (Exception e){ |
268 |
> |
} catch (Exception e) { |
269 |
|
threadUnexpectedException(); |
270 |
|
} |
271 |
|
} |
278 |
|
t.join(); |
279 |
|
assertTrue(ft.isDone()); |
280 |
|
assertFalse(ft.isCancelled()); |
281 |
< |
} catch (InterruptedException e){ |
281 |
> |
} catch (InterruptedException e) { |
282 |
|
unexpectedException(); |
283 |
|
|
284 |
|
} |
305 |
|
ft.get(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
306 |
|
threadShouldThrow(); |
307 |
|
} catch (CancellationException success) {} |
308 |
< |
catch (Exception e){ |
308 |
> |
catch (Exception e) { |
309 |
|
threadUnexpectedException(); |
310 |
|
} |
311 |
|
} |
317 |
|
ft.cancel(true); |
318 |
|
t1.join(); |
319 |
|
t2.join(); |
320 |
< |
} catch (InterruptedException ie){ |
320 |
> |
} catch (InterruptedException ie) { |
321 |
|
unexpectedException(); |
322 |
|
} |
323 |
|
} |
331 |
|
try { |
332 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
333 |
|
threadShouldThrow(); |
334 |
< |
} catch (InterruptedException e){ |
334 |
> |
} catch (InterruptedException e) { |
335 |
|
} |
336 |
|
return Boolean.TRUE; |
337 |
|
} |
342 |
|
try { |
343 |
|
ft.get(); |
344 |
|
threadShouldThrow(); |
345 |
< |
} catch (CancellationException success){ |
345 |
> |
} catch (CancellationException success) { |
346 |
|
} |
347 |
< |
catch (Exception e){ |
347 |
> |
catch (Exception e) { |
348 |
|
threadUnexpectedException(); |
349 |
|
} |
350 |
|
} |
356 |
|
ft.cancel(true); |
357 |
|
t1.join(); |
358 |
|
t2.join(); |
359 |
< |
} catch (InterruptedException success){ |
359 |
> |
} catch (InterruptedException success) { |
360 |
|
unexpectedException(); |
361 |
|
} |
362 |
|
} |
376 |
|
ft.run(); |
377 |
|
ft.get(); |
378 |
|
shouldThrow(); |
379 |
< |
} catch (ExecutionException success){ |
379 |
> |
} catch (ExecutionException success) { |
380 |
|
} |
381 |
< |
catch (Exception e){ |
381 |
> |
catch (Exception e) { |
382 |
|
unexpectedException(); |
383 |
|
} |
384 |
|
} |
399 |
|
shouldThrow(); |
400 |
|
} catch (ExecutionException success) { |
401 |
|
} catch (TimeoutException success) { } // unlikely but OK |
402 |
< |
catch (Exception e){ |
402 |
> |
catch (Exception e) { |
403 |
|
unexpectedException(); |
404 |
|
} |
405 |
|
} |
415 |
|
try { |
416 |
|
ft.get(); |
417 |
|
threadShouldThrow(); |
418 |
< |
} catch (InterruptedException success){ |
419 |
< |
} catch (Exception e){ |
418 |
> |
} catch (InterruptedException success) { |
419 |
> |
} catch (Exception e) { |
420 |
|
threadUnexpectedException(); |
421 |
|
} |
422 |
|
} |
426 |
|
Thread.sleep(SHORT_DELAY_MS); |
427 |
|
t.interrupt(); |
428 |
|
t.join(); |
429 |
< |
} catch (Exception e){ |
429 |
> |
} catch (Exception e) { |
430 |
|
unexpectedException(); |
431 |
|
} |
432 |
|
} |
441 |
|
try { |
442 |
|
ft.get(LONG_DELAY_MS,TimeUnit.MILLISECONDS); |
443 |
|
threadShouldThrow(); |
444 |
< |
} catch (InterruptedException success){} |
445 |
< |
catch (Exception e){ |
444 |
> |
} catch (InterruptedException success) {} |
445 |
> |
catch (Exception e) { |
446 |
|
threadUnexpectedException(); |
447 |
|
} |
448 |
|
} |
452 |
|
Thread.sleep(SHORT_DELAY_MS); |
453 |
|
t.interrupt(); |
454 |
|
t.join(); |
455 |
< |
} catch (Exception e){ |
455 |
> |
} catch (Exception e) { |
456 |
|
unexpectedException(); |
457 |
|
} |
458 |
|
} |
465 |
|
FutureTask ft = new FutureTask(new NoOpCallable()); |
466 |
|
ft.get(1,TimeUnit.MILLISECONDS); |
467 |
|
shouldThrow(); |
468 |
< |
} catch (TimeoutException success){} |
469 |
< |
catch (Exception success){ |
468 |
> |
} catch (TimeoutException success) {} |
469 |
> |
catch (Exception success) { |
470 |
|
unexpectedException(); |
471 |
|
} |
472 |
|
} |