29 |
|
p1.execute(runnable); |
30 |
|
assertFalse(runnable.done); |
31 |
|
Thread.sleep(SHORT_DELAY_MS); |
32 |
< |
p1.shutdown(); |
32 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
33 |
|
try { |
34 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
35 |
|
} catch(InterruptedException e){ |
36 |
|
unexpectedException(); |
37 |
|
} |
38 |
|
assertTrue(runnable.done); |
39 |
< |
p1.shutdown(); |
39 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
40 |
|
joinPool(p1); |
41 |
|
} |
42 |
|
catch(Exception e){ |
58 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
59 |
|
assertTrue(callable.done); |
60 |
|
assertEquals(Boolean.TRUE, f.get()); |
61 |
< |
p1.shutdown(); |
61 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
62 |
|
joinPool(p1); |
63 |
|
} catch(RejectedExecutionException e){} |
64 |
|
catch(Exception e){ |
79 |
|
assertFalse(runnable.done); |
80 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
81 |
|
assertTrue(runnable.done); |
82 |
< |
p1.shutdown(); |
82 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
83 |
|
joinPool(p1); |
84 |
|
} catch(Exception e){ |
85 |
|
unexpectedException(); |
98 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
99 |
|
assertTrue(runnable.done); |
100 |
|
h.cancel(true); |
101 |
– |
p1.shutdown(); |
101 |
|
joinPool(p1); |
102 |
|
} catch(Exception e){ |
103 |
|
unexpectedException(); |
116 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
117 |
|
assertTrue(runnable.done); |
118 |
|
h.cancel(true); |
120 |
– |
p1.shutdown(); |
119 |
|
joinPool(p1); |
120 |
|
} catch(Exception e){ |
121 |
|
unexpectedException(); |
166 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
167 |
|
shouldThrow(); |
168 |
|
} catch(RejectedExecutionException success){ |
169 |
+ |
} catch (SecurityException ok) { |
170 |
|
} |
171 |
+ |
|
172 |
|
joinPool(se); |
173 |
|
|
174 |
|
} |
184 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
185 |
|
shouldThrow(); |
186 |
|
} catch(RejectedExecutionException success){ |
187 |
+ |
} catch (SecurityException ok) { |
188 |
|
} |
189 |
|
joinPool(se); |
190 |
|
} |
200 |
|
MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
201 |
|
shouldThrow(); |
202 |
|
} catch(RejectedExecutionException success){ |
203 |
< |
} |
203 |
> |
} catch (SecurityException ok) { |
204 |
> |
} |
205 |
|
joinPool(se); |
206 |
|
} |
207 |
|
|
216 |
|
MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
217 |
|
shouldThrow(); |
218 |
|
} catch(RejectedExecutionException success){ |
219 |
+ |
} catch (SecurityException ok) { |
220 |
|
} |
221 |
|
joinPool(se); |
222 |
|
} |
232 |
|
MEDIUM_DELAY_MS, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
233 |
|
shouldThrow(); |
234 |
|
} catch(RejectedExecutionException success){ |
235 |
+ |
} catch (SecurityException ok) { |
236 |
|
} |
237 |
|
joinPool(se); |
238 |
|
} |
335 |
|
ThreadFactory tf = new SimpleThreadFactory(); |
336 |
|
ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf); |
337 |
|
assertSame(tf, p.getThreadFactory()); |
334 |
– |
p.shutdown(); |
338 |
|
joinPool(p); |
339 |
|
} |
340 |
|
|
346 |
|
ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
347 |
|
p.setThreadFactory(tf); |
348 |
|
assertSame(tf, p.getThreadFactory()); |
346 |
– |
p.shutdown(); |
349 |
|
joinPool(p); |
350 |
|
} |
351 |
|
|
373 |
|
assertFalse(p1.isShutdown()); |
374 |
|
} |
375 |
|
finally { |
376 |
< |
p1.shutdown(); |
376 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
377 |
|
} |
378 |
|
assertTrue(p1.isShutdown()); |
379 |
|
} |
387 |
|
try { |
388 |
|
p1.execute(new SmallRunnable()); |
389 |
|
} finally { |
390 |
< |
p1.shutdown(); |
390 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
391 |
|
} |
392 |
|
try { |
393 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
407 |
|
p1.execute(new SmallRunnable()); |
408 |
|
assertFalse(p1.isTerminating()); |
409 |
|
} finally { |
410 |
< |
p1.shutdown(); |
410 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
411 |
|
} |
412 |
|
try { |
413 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
432 |
|
BlockingQueue<Runnable> q = p1.getQueue(); |
433 |
|
assertTrue(q.contains(tasks[4])); |
434 |
|
assertFalse(q.contains(tasks[0])); |
433 |
– |
p1.shutdownNow(); |
435 |
|
} catch(Exception e) { |
436 |
|
unexpectedException(); |
437 |
|
} finally { |
460 |
|
assertTrue(q.contains((Runnable)tasks[3])); |
461 |
|
assertTrue(p1.remove((Runnable)tasks[3])); |
462 |
|
assertFalse(q.contains((Runnable)tasks[3])); |
462 |
– |
p1.shutdownNow(); |
463 |
|
} catch(Exception e) { |
464 |
|
unexpectedException(); |
465 |
|
} finally { |
492 |
|
ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1); |
493 |
|
for(int i = 0; i < 5; i++) |
494 |
|
p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
495 |
< |
List l = p1.shutdownNow(); |
495 |
> |
List l; |
496 |
> |
try { |
497 |
> |
l = p1.shutdownNow(); |
498 |
> |
} catch (SecurityException ok) { |
499 |
> |
return; |
500 |
> |
} |
501 |
|
assertTrue(p1.isShutdown()); |
502 |
|
assertTrue(l.size() > 0 && l.size() <= 5); |
503 |
|
joinPool(p1); |
516 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
517 |
|
for(int i = 0; i < 5; i++) |
518 |
|
tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
519 |
< |
p1.shutdown(); |
519 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
520 |
|
BlockingQueue q = p1.getQueue(); |
521 |
|
for (Iterator it = q.iterator(); it.hasNext();) { |
522 |
|
ScheduledFuture t = (ScheduledFuture)it.next(); |
547 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
548 |
|
for(int i = 0; i < 5; i++) |
549 |
|
tasks[i] = p1.schedule(new NoOpRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
550 |
< |
p1.shutdown(); |
550 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
551 |
|
assertTrue(p1.isShutdown()); |
552 |
|
BlockingQueue q = p1.getQueue(); |
553 |
|
assertTrue(q.isEmpty()); |
570 |
|
p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); |
571 |
|
ScheduledFuture task = |
572 |
|
p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS); |
573 |
< |
p1.shutdown(); |
573 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
574 |
|
assertTrue(p1.isShutdown()); |
575 |
|
BlockingQueue q = p1.getQueue(); |
576 |
|
assertTrue(q.isEmpty()); |
591 |
|
try { |
592 |
|
p1.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); |
593 |
|
ScheduledFuture task = |
594 |
< |
p1.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, TimeUnit.MILLISECONDS); |
594 |
> |
p1.scheduleAtFixedRate(new NoOpRunnable(), 1, 1, TimeUnit.MILLISECONDS); |
595 |
|
assertFalse(task.isCancelled()); |
596 |
< |
p1.shutdown(); |
596 |
> |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
597 |
|
assertFalse(task.isCancelled()); |
598 |
|
assertFalse(p1.isTerminated()); |
599 |
|
assertTrue(p1.isShutdown()); |
600 |
|
Thread.sleep(SHORT_DELAY_MS); |
601 |
|
assertFalse(task.isCancelled()); |
602 |
< |
task.cancel(true); |
602 |
> |
assertTrue(task.cancel(true)); |
603 |
|
assertTrue(task.isDone()); |
604 |
|
Thread.sleep(SHORT_DELAY_MS); |
605 |
|
assertTrue(p1.isTerminated()); |
607 |
|
catch(Exception ex) { |
608 |
|
unexpectedException(); |
609 |
|
} |
610 |
< |
finally { |
611 |
< |
p1.shutdownNow(); |
610 |
> |
finally { |
611 |
> |
joinPool(p1); |
612 |
|
} |
613 |
|
} |
614 |
|
|