68 |
|
try { |
69 |
|
v = callable.call(); |
70 |
|
} |
71 |
< |
catch(Exception ex) { |
71 |
> |
catch (Exception ex) { |
72 |
|
e = ex; |
73 |
|
} |
74 |
|
lock.lock(); |
195 |
|
public void run() { |
196 |
|
try { |
197 |
|
Thread.sleep(SHORT_DELAY_MS); |
198 |
< |
} catch(InterruptedException e){ |
198 |
> |
} catch (InterruptedException e){ |
199 |
|
threadUnexpectedException(); |
200 |
|
} |
201 |
|
} |
202 |
|
}); |
203 |
|
Thread.sleep(SMALL_DELAY_MS); |
204 |
< |
} catch(InterruptedException e){ |
204 |
> |
} catch (InterruptedException e){ |
205 |
|
unexpectedException(); |
206 |
|
} |
207 |
|
joinPool(p1); |
217 |
|
p2.execute(new MediumRunnable()); |
218 |
|
try { |
219 |
|
Thread.sleep(SHORT_DELAY_MS); |
220 |
< |
} catch(Exception e){ |
220 |
> |
} catch (Exception e){ |
221 |
|
unexpectedException(); |
222 |
|
} |
223 |
|
assertEquals(1, p2.getActiveCount()); |
262 |
|
p2.execute(new ShortRunnable()); |
263 |
|
try { |
264 |
|
Thread.sleep(SMALL_DELAY_MS); |
265 |
< |
} catch(Exception e){ |
265 |
> |
} catch (Exception e){ |
266 |
|
unexpectedException(); |
267 |
|
} |
268 |
|
assertEquals(1, p2.getCompletedTaskCount()); |
269 |
< |
try { p2.shutdown(); } catch(SecurityException ok) { return; } |
269 |
> |
try { p2.shutdown(); } catch (SecurityException ok) { return; } |
270 |
|
joinPool(p2); |
271 |
|
} |
272 |
|
|
375 |
|
p2.execute(new MediumRunnable()); |
376 |
|
Thread.sleep(SHORT_DELAY_MS); |
377 |
|
assertEquals(2, p2.getLargestPoolSize()); |
378 |
< |
} catch(Exception e){ |
378 |
> |
} catch (Exception e){ |
379 |
|
unexpectedException(); |
380 |
|
} |
381 |
|
joinPool(p2); |
413 |
|
p1.execute(new MediumRunnable()); |
414 |
|
Thread.sleep(SHORT_DELAY_MS); |
415 |
|
assertEquals(1, p1.getTaskCount()); |
416 |
< |
} catch(Exception e){ |
416 |
> |
} catch (Exception e){ |
417 |
|
unexpectedException(); |
418 |
|
} |
419 |
|
joinPool(p1); |
426 |
|
|
427 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
428 |
|
assertFalse(p1.isShutdown()); |
429 |
< |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
429 |
> |
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
430 |
|
assertTrue(p1.isShutdown()); |
431 |
|
joinPool(p1); |
432 |
|
} |
441 |
|
try { |
442 |
|
p1.execute(new MediumRunnable()); |
443 |
|
} finally { |
444 |
< |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
444 |
> |
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
445 |
|
} |
446 |
|
try { |
447 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
448 |
|
assertTrue(p1.isTerminated()); |
449 |
< |
} catch(Exception e){ |
449 |
> |
} catch (Exception e){ |
450 |
|
unexpectedException(); |
451 |
|
} |
452 |
|
} |
461 |
|
p1.execute(new SmallRunnable()); |
462 |
|
assertFalse(p1.isTerminating()); |
463 |
|
} finally { |
464 |
< |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
464 |
> |
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
465 |
|
} |
466 |
|
try { |
467 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
468 |
|
assertTrue(p1.isTerminated()); |
469 |
|
assertFalse(p1.isTerminating()); |
470 |
< |
} catch(Exception e){ |
470 |
> |
} catch (Exception e){ |
471 |
|
unexpectedException(); |
472 |
|
} |
473 |
|
} |
479 |
|
BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10); |
480 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); |
481 |
|
FutureTask[] tasks = new FutureTask[5]; |
482 |
< |
for(int i = 0; i < 5; i++){ |
482 |
> |
for (int i = 0; i < 5; i++){ |
483 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
484 |
|
p1.execute(tasks[i]); |
485 |
|
} |
492 |
|
for (int i = 1; i < 5; ++i) |
493 |
|
tasks[i].cancel(true); |
494 |
|
p1.shutdownNow(); |
495 |
< |
} catch(Exception e) { |
495 |
> |
} catch (Exception e) { |
496 |
|
unexpectedException(); |
497 |
|
} finally { |
498 |
|
joinPool(p1); |
506 |
|
BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10); |
507 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); |
508 |
|
FutureTask[] tasks = new FutureTask[5]; |
509 |
< |
for(int i = 0; i < 5; i++){ |
509 |
> |
for (int i = 0; i < 5; i++){ |
510 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
511 |
|
p1.execute(tasks[i]); |
512 |
|
} |
521 |
|
assertTrue(q.contains(tasks[3])); |
522 |
|
assertTrue(p1.remove(tasks[3])); |
523 |
|
assertFalse(q.contains(tasks[3])); |
524 |
< |
} catch(Exception e) { |
524 |
> |
} catch (Exception e) { |
525 |
|
unexpectedException(); |
526 |
|
} finally { |
527 |
|
joinPool(p1); |
534 |
|
public void testPurge() { |
535 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
536 |
|
FutureTask[] tasks = new FutureTask[5]; |
537 |
< |
for(int i = 0; i < 5; i++){ |
537 |
> |
for (int i = 0; i < 5; i++){ |
538 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
539 |
|
p1.execute(tasks[i]); |
540 |
|
} |
553 |
|
ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
554 |
|
List l; |
555 |
|
try { |
556 |
< |
for(int i = 0; i < 5; i++) |
556 |
> |
for (int i = 0; i < 5; i++) |
557 |
|
p1.execute(new MediumPossiblyInterruptedRunnable()); |
558 |
|
} |
559 |
|
finally { |
893 |
|
ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); |
894 |
|
try { |
895 |
|
|
896 |
< |
for(int i = 0; i < 5; ++i){ |
896 |
> |
for (int i = 0; i < 5; ++i){ |
897 |
|
p.execute(new MediumRunnable()); |
898 |
|
} |
899 |
|
shouldThrow(); |
900 |
< |
} catch(RejectedExecutionException success){} |
900 |
> |
} catch (RejectedExecutionException success){} |
901 |
|
joinPool(p); |
902 |
|
} |
903 |
|
|
910 |
|
try { |
911 |
|
|
912 |
|
TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; |
913 |
< |
for(int i = 0; i < 5; ++i){ |
913 |
> |
for (int i = 0; i < 5; ++i){ |
914 |
|
tasks[i] = new TrackedNoOpRunnable(); |
915 |
|
} |
916 |
|
TrackedLongRunnable mr = new TrackedLongRunnable(); |
917 |
|
p.execute(mr); |
918 |
< |
for(int i = 0; i < 5; ++i){ |
918 |
> |
for (int i = 0; i < 5; ++i){ |
919 |
|
p.execute(tasks[i]); |
920 |
|
} |
921 |
< |
for(int i = 1; i < 5; ++i) { |
921 |
> |
for (int i = 1; i < 5; ++i) { |
922 |
|
assertTrue(tasks[i].done); |
923 |
|
} |
924 |
< |
try { p.shutdownNow(); } catch(SecurityException ok) { return; } |
925 |
< |
} catch(RejectedExecutionException ex){ |
924 |
> |
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
925 |
> |
} catch (RejectedExecutionException ex){ |
926 |
|
unexpectedException(); |
927 |
|
} finally { |
928 |
|
joinPool(p); |
938 |
|
try { |
939 |
|
|
940 |
|
TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; |
941 |
< |
for(int i = 0; i < 5; ++i){ |
941 |
> |
for (int i = 0; i < 5; ++i){ |
942 |
|
tasks[i] = new TrackedNoOpRunnable(); |
943 |
|
} |
944 |
|
p.execute(new TrackedLongRunnable()); |
945 |
< |
for(int i = 0; i < 5; ++i){ |
945 |
> |
for (int i = 0; i < 5; ++i){ |
946 |
|
p.execute(tasks[i]); |
947 |
|
} |
948 |
< |
for(int i = 0; i < 5; ++i){ |
948 |
> |
for (int i = 0; i < 5; ++i){ |
949 |
|
assertFalse(tasks[i].done); |
950 |
|
} |
951 |
< |
try { p.shutdownNow(); } catch(SecurityException ok) { return; } |
952 |
< |
} catch(RejectedExecutionException ex){ |
951 |
> |
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
952 |
> |
} catch (RejectedExecutionException ex){ |
953 |
|
unexpectedException(); |
954 |
|
} finally { |
955 |
|
joinPool(p); |
971 |
|
p.execute(r3); |
972 |
|
assertFalse(p.getQueue().contains(r2)); |
973 |
|
assertTrue(p.getQueue().contains(r3)); |
974 |
< |
try { p.shutdownNow(); } catch(SecurityException ok) { return; } |
975 |
< |
} catch(RejectedExecutionException ex){ |
974 |
> |
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
975 |
> |
} catch (RejectedExecutionException ex){ |
976 |
|
unexpectedException(); |
977 |
|
} finally { |
978 |
|
joinPool(p); |
985 |
|
public void testRejectedExecutionExceptionOnShutdown() { |
986 |
|
ThreadPoolExecutor tpe = |
987 |
|
new CustomTPE(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(1)); |
988 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
988 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
989 |
|
try { |
990 |
|
tpe.execute(new NoOpRunnable()); |
991 |
|
shouldThrow(); |
992 |
< |
} catch(RejectedExecutionException success){} |
992 |
> |
} catch (RejectedExecutionException success){} |
993 |
|
|
994 |
|
joinPool(tpe); |
995 |
|
} |
1001 |
|
RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy(); |
1002 |
|
ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h); |
1003 |
|
|
1004 |
< |
try { p.shutdown(); } catch(SecurityException ok) { return; } |
1004 |
> |
try { p.shutdown(); } catch (SecurityException ok) { return; } |
1005 |
|
try { |
1006 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
1007 |
|
p.execute(r); |
1008 |
|
assertFalse(r.done); |
1009 |
< |
} catch(RejectedExecutionException success){ |
1009 |
> |
} catch (RejectedExecutionException success){ |
1010 |
|
unexpectedException(); |
1011 |
|
} finally { |
1012 |
|
joinPool(p); |
1020 |
|
RejectedExecutionHandler h = new CustomTPE.DiscardPolicy(); |
1021 |
|
ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h); |
1022 |
|
|
1023 |
< |
try { p.shutdown(); } catch(SecurityException ok) { return; } |
1023 |
> |
try { p.shutdown(); } catch (SecurityException ok) { return; } |
1024 |
|
try { |
1025 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
1026 |
|
p.execute(r); |
1027 |
|
assertFalse(r.done); |
1028 |
< |
} catch(RejectedExecutionException success){ |
1028 |
> |
} catch (RejectedExecutionException success){ |
1029 |
|
unexpectedException(); |
1030 |
|
} finally { |
1031 |
|
joinPool(p); |
1040 |
|
RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy(); |
1041 |
|
ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h); |
1042 |
|
|
1043 |
< |
try { p.shutdown(); } catch(SecurityException ok) { return; } |
1043 |
> |
try { p.shutdown(); } catch (SecurityException ok) { return; } |
1044 |
|
try { |
1045 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
1046 |
|
p.execute(r); |
1047 |
|
assertFalse(r.done); |
1048 |
< |
} catch(RejectedExecutionException success){ |
1048 |
> |
} catch (RejectedExecutionException success){ |
1049 |
|
unexpectedException(); |
1050 |
|
} finally { |
1051 |
|
joinPool(p); |
1062 |
|
tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1063 |
|
tpe.execute(null); |
1064 |
|
shouldThrow(); |
1065 |
< |
} catch(NullPointerException success){} |
1065 |
> |
} catch (NullPointerException success){} |
1066 |
|
|
1067 |
|
joinPool(tpe); |
1068 |
|
} |
1074 |
|
ThreadPoolExecutor tpe = null; |
1075 |
|
try { |
1076 |
|
tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1077 |
< |
} catch(Exception e){} |
1077 |
> |
} catch (Exception e){} |
1078 |
|
try { |
1079 |
|
tpe.setCorePoolSize(-1); |
1080 |
|
shouldThrow(); |
1081 |
< |
} catch(IllegalArgumentException success){ |
1081 |
> |
} catch (IllegalArgumentException success){ |
1082 |
|
} finally { |
1083 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1083 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1084 |
|
} |
1085 |
|
joinPool(tpe); |
1086 |
|
} |
1093 |
|
ThreadPoolExecutor tpe = null; |
1094 |
|
try { |
1095 |
|
tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1096 |
< |
} catch(Exception e){} |
1096 |
> |
} catch (Exception e){} |
1097 |
|
try { |
1098 |
|
tpe.setMaximumPoolSize(1); |
1099 |
|
shouldThrow(); |
1100 |
< |
} catch(IllegalArgumentException success){ |
1100 |
> |
} catch (IllegalArgumentException success){ |
1101 |
|
} finally { |
1102 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1102 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1103 |
|
} |
1104 |
|
joinPool(tpe); |
1105 |
|
} |
1112 |
|
ThreadPoolExecutor tpe = null; |
1113 |
|
try { |
1114 |
|
tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1115 |
< |
} catch(Exception e){} |
1115 |
> |
} catch (Exception e){} |
1116 |
|
try { |
1117 |
|
tpe.setMaximumPoolSize(-1); |
1118 |
|
shouldThrow(); |
1119 |
< |
} catch(IllegalArgumentException success){ |
1119 |
> |
} catch (IllegalArgumentException success){ |
1120 |
|
} finally { |
1121 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1121 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1122 |
|
} |
1123 |
|
joinPool(tpe); |
1124 |
|
} |
1132 |
|
ThreadPoolExecutor tpe = null; |
1133 |
|
try { |
1134 |
|
tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1135 |
< |
} catch(Exception e){} |
1135 |
> |
} catch (Exception e){} |
1136 |
|
|
1137 |
|
try { |
1138 |
|
tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS); |
1139 |
|
shouldThrow(); |
1140 |
< |
} catch(IllegalArgumentException success){ |
1140 |
> |
} catch (IllegalArgumentException success){ |
1141 |
|
} finally { |
1142 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1142 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1143 |
|
} |
1144 |
|
joinPool(tpe); |
1145 |
|
} |
1149 |
|
*/ |
1150 |
|
public void testTerminated() { |
1151 |
|
CustomTPE tpe = new CustomTPE(); |
1152 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1152 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1153 |
|
assertTrue(tpe.terminatedCalled); |
1154 |
|
joinPool(tpe); |
1155 |
|
} |
1166 |
|
assertTrue(r.done); |
1167 |
|
assertTrue(tpe.beforeCalled); |
1168 |
|
assertTrue(tpe.afterCalled); |
1169 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1169 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1170 |
|
} |
1171 |
< |
catch(Exception ex) { |
1171 |
> |
catch (Exception ex) { |
1172 |
|
unexpectedException(); |
1173 |
|
} finally { |
1174 |
|
joinPool(tpe); |
1247 |
|
try { |
1248 |
|
e.invokeAny(null); |
1249 |
|
} catch (NullPointerException success) { |
1250 |
< |
} catch(Exception ex) { |
1250 |
> |
} catch (Exception ex) { |
1251 |
|
unexpectedException(); |
1252 |
|
} finally { |
1253 |
|
joinPool(e); |
1262 |
|
try { |
1263 |
|
e.invokeAny(new ArrayList<Callable<String>>()); |
1264 |
|
} catch (IllegalArgumentException success) { |
1265 |
< |
} catch(Exception ex) { |
1265 |
> |
} catch (Exception ex) { |
1266 |
|
unexpectedException(); |
1267 |
|
} finally { |
1268 |
|
joinPool(e); |
1280 |
|
l.add(null); |
1281 |
|
e.invokeAny(l); |
1282 |
|
} catch (NullPointerException success) { |
1283 |
< |
} catch(Exception ex) { |
1283 |
> |
} catch (Exception ex) { |
1284 |
|
unexpectedException(); |
1285 |
|
} finally { |
1286 |
|
joinPool(e); |
1297 |
|
l.add(new NPETask()); |
1298 |
|
e.invokeAny(l); |
1299 |
|
} catch (ExecutionException success) { |
1300 |
< |
} catch(Exception ex) { |
1300 |
> |
} catch (Exception ex) { |
1301 |
|
unexpectedException(); |
1302 |
|
} finally { |
1303 |
|
joinPool(e); |
1316 |
|
String result = e.invokeAny(l); |
1317 |
|
assertSame(TEST_STRING, result); |
1318 |
|
} catch (ExecutionException success) { |
1319 |
< |
} catch(Exception ex) { |
1319 |
> |
} catch (Exception ex) { |
1320 |
|
unexpectedException(); |
1321 |
|
} finally { |
1322 |
|
joinPool(e); |
1331 |
|
try { |
1332 |
|
e.invokeAll(null); |
1333 |
|
} catch (NullPointerException success) { |
1334 |
< |
} catch(Exception ex) { |
1334 |
> |
} catch (Exception ex) { |
1335 |
|
unexpectedException(); |
1336 |
|
} finally { |
1337 |
|
joinPool(e); |
1346 |
|
try { |
1347 |
|
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>()); |
1348 |
|
assertTrue(r.isEmpty()); |
1349 |
< |
} catch(Exception ex) { |
1349 |
> |
} catch (Exception ex) { |
1350 |
|
unexpectedException(); |
1351 |
|
} finally { |
1352 |
|
joinPool(e); |
1364 |
|
l.add(null); |
1365 |
|
e.invokeAll(l); |
1366 |
|
} catch (NullPointerException success) { |
1367 |
< |
} catch(Exception ex) { |
1367 |
> |
} catch (Exception ex) { |
1368 |
|
unexpectedException(); |
1369 |
|
} finally { |
1370 |
|
joinPool(e); |
1383 |
|
assertEquals(1, result.size()); |
1384 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1385 |
|
it.next().get(); |
1386 |
< |
} catch(ExecutionException success) { |
1387 |
< |
} catch(Exception ex) { |
1386 |
> |
} catch (ExecutionException success) { |
1387 |
> |
} catch (Exception ex) { |
1388 |
|
unexpectedException(); |
1389 |
|
} finally { |
1390 |
|
joinPool(e); |
1405 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1406 |
|
assertSame(TEST_STRING, it.next().get()); |
1407 |
|
} catch (ExecutionException success) { |
1408 |
< |
} catch(Exception ex) { |
1408 |
> |
} catch (Exception ex) { |
1409 |
|
unexpectedException(); |
1410 |
|
} finally { |
1411 |
|
joinPool(e); |
1422 |
|
try { |
1423 |
|
e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1424 |
|
} catch (NullPointerException success) { |
1425 |
< |
} catch(Exception ex) { |
1425 |
> |
} catch (Exception ex) { |
1426 |
|
unexpectedException(); |
1427 |
|
} finally { |
1428 |
|
joinPool(e); |
1439 |
|
l.add(new StringTask()); |
1440 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, null); |
1441 |
|
} catch (NullPointerException success) { |
1442 |
< |
} catch(Exception ex) { |
1442 |
> |
} catch (Exception ex) { |
1443 |
|
unexpectedException(); |
1444 |
|
} finally { |
1445 |
|
joinPool(e); |
1454 |
|
try { |
1455 |
|
e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1456 |
|
} catch (IllegalArgumentException success) { |
1457 |
< |
} catch(Exception ex) { |
1457 |
> |
} catch (Exception ex) { |
1458 |
|
unexpectedException(); |
1459 |
|
} finally { |
1460 |
|
joinPool(e); |
1472 |
|
l.add(null); |
1473 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1474 |
|
} catch (NullPointerException success) { |
1475 |
< |
} catch(Exception ex) { |
1475 |
> |
} catch (Exception ex) { |
1476 |
|
ex.printStackTrace(); |
1477 |
|
unexpectedException(); |
1478 |
|
} finally { |
1489 |
|
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
1490 |
|
l.add(new NPETask()); |
1491 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1492 |
< |
} catch(ExecutionException success) { |
1493 |
< |
} catch(Exception ex) { |
1492 |
> |
} catch (ExecutionException success) { |
1493 |
> |
} catch (Exception ex) { |
1494 |
|
unexpectedException(); |
1495 |
|
} finally { |
1496 |
|
joinPool(e); |
1509 |
|
String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1510 |
|
assertSame(TEST_STRING, result); |
1511 |
|
} catch (ExecutionException success) { |
1512 |
< |
} catch(Exception ex) { |
1512 |
> |
} catch (Exception ex) { |
1513 |
|
unexpectedException(); |
1514 |
|
} finally { |
1515 |
|
joinPool(e); |
1524 |
|
try { |
1525 |
|
e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1526 |
|
} catch (NullPointerException success) { |
1527 |
< |
} catch(Exception ex) { |
1527 |
> |
} catch (Exception ex) { |
1528 |
|
unexpectedException(); |
1529 |
|
} finally { |
1530 |
|
joinPool(e); |
1541 |
|
l.add(new StringTask()); |
1542 |
|
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
1543 |
|
} catch (NullPointerException success) { |
1544 |
< |
} catch(Exception ex) { |
1544 |
> |
} catch (Exception ex) { |
1545 |
|
unexpectedException(); |
1546 |
|
} finally { |
1547 |
|
joinPool(e); |
1556 |
|
try { |
1557 |
|
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1558 |
|
assertTrue(r.isEmpty()); |
1559 |
< |
} catch(Exception ex) { |
1559 |
> |
} catch (Exception ex) { |
1560 |
|
unexpectedException(); |
1561 |
|
} finally { |
1562 |
|
joinPool(e); |
1574 |
|
l.add(null); |
1575 |
|
e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1576 |
|
} catch (NullPointerException success) { |
1577 |
< |
} catch(Exception ex) { |
1577 |
> |
} catch (Exception ex) { |
1578 |
|
unexpectedException(); |
1579 |
|
} finally { |
1580 |
|
joinPool(e); |
1593 |
|
assertEquals(1, result.size()); |
1594 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1595 |
|
it.next().get(); |
1596 |
< |
} catch(ExecutionException success) { |
1597 |
< |
} catch(Exception ex) { |
1596 |
> |
} catch (ExecutionException success) { |
1597 |
> |
} catch (Exception ex) { |
1598 |
|
unexpectedException(); |
1599 |
|
} finally { |
1600 |
|
joinPool(e); |
1615 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1616 |
|
assertSame(TEST_STRING, it.next().get()); |
1617 |
|
} catch (ExecutionException success) { |
1618 |
< |
} catch(Exception ex) { |
1618 |
> |
} catch (Exception ex) { |
1619 |
|
unexpectedException(); |
1620 |
|
} finally { |
1621 |
|
joinPool(e); |
1643 |
|
assertTrue(f3.isDone()); |
1644 |
|
assertFalse(f1.isCancelled()); |
1645 |
|
assertTrue(f2.isCancelled()); |
1646 |
< |
} catch(Exception ex) { |
1646 |
> |
} catch (Exception ex) { |
1647 |
|
unexpectedException(); |
1648 |
|
} finally { |
1649 |
|
joinPool(e); |
1662 |
|
e.execute(new NoOpRunnable()); |
1663 |
|
} |
1664 |
|
Thread.sleep(LONG_DELAY_MS); |
1665 |
< |
} catch(Exception ex) { |
1665 |
> |
} catch (Exception ex) { |
1666 |
|
unexpectedException(); |
1667 |
|
} finally { |
1668 |
|
joinPool(e); |
1688 |
|
try { |
1689 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
1690 |
|
assertEquals(0, tpe.getPoolSize()); |
1691 |
< |
} catch(InterruptedException e){ |
1691 |
> |
} catch (InterruptedException e){ |
1692 |
|
unexpectedException(); |
1693 |
|
} finally { |
1694 |
|
joinPool(tpe); |
1705 |
|
try { |
1706 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
1707 |
|
assertTrue(tpe.getPoolSize() >= 1); |
1708 |
< |
} catch(InterruptedException e){ |
1708 |
> |
} catch (InterruptedException e){ |
1709 |
|
unexpectedException(); |
1710 |
|
} finally { |
1711 |
|
joinPool(tpe); |