56 |
|
public void run() { |
57 |
|
try { |
58 |
|
Thread.sleep(SHORT_DELAY_MS); |
59 |
< |
} catch(InterruptedException e){ |
59 |
> |
} catch (InterruptedException e){ |
60 |
|
threadUnexpectedException(); |
61 |
|
} |
62 |
|
} |
63 |
|
}); |
64 |
|
Thread.sleep(SMALL_DELAY_MS); |
65 |
< |
} catch(InterruptedException e){ |
65 |
> |
} catch (InterruptedException e){ |
66 |
|
unexpectedException(); |
67 |
|
} |
68 |
|
joinPool(p1); |
78 |
|
p2.execute(new MediumRunnable()); |
79 |
|
try { |
80 |
|
Thread.sleep(SHORT_DELAY_MS); |
81 |
< |
} catch(Exception e){ |
81 |
> |
} catch (Exception e){ |
82 |
|
unexpectedException(); |
83 |
|
} |
84 |
|
assertEquals(1, p2.getActiveCount()); |
123 |
|
p2.execute(new ShortRunnable()); |
124 |
|
try { |
125 |
|
Thread.sleep(SMALL_DELAY_MS); |
126 |
< |
} catch(Exception e){ |
126 |
> |
} catch (Exception e){ |
127 |
|
unexpectedException(); |
128 |
|
} |
129 |
|
assertEquals(1, p2.getCompletedTaskCount()); |
130 |
< |
try { p2.shutdown(); } catch(SecurityException ok) { return; } |
130 |
> |
try { p2.shutdown(); } catch (SecurityException ok) { return; } |
131 |
|
joinPool(p2); |
132 |
|
} |
133 |
|
|
236 |
|
p2.execute(new MediumRunnable()); |
237 |
|
Thread.sleep(SHORT_DELAY_MS); |
238 |
|
assertEquals(2, p2.getLargestPoolSize()); |
239 |
< |
} catch(Exception e){ |
239 |
> |
} catch (Exception e){ |
240 |
|
unexpectedException(); |
241 |
|
} |
242 |
|
joinPool(p2); |
274 |
|
p1.execute(new MediumRunnable()); |
275 |
|
Thread.sleep(SHORT_DELAY_MS); |
276 |
|
assertEquals(1, p1.getTaskCount()); |
277 |
< |
} catch(Exception e){ |
277 |
> |
} catch (Exception e){ |
278 |
|
unexpectedException(); |
279 |
|
} |
280 |
|
joinPool(p1); |
287 |
|
|
288 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
289 |
|
assertFalse(p1.isShutdown()); |
290 |
< |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
290 |
> |
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
291 |
|
assertTrue(p1.isShutdown()); |
292 |
|
joinPool(p1); |
293 |
|
} |
302 |
|
try { |
303 |
|
p1.execute(new MediumRunnable()); |
304 |
|
} finally { |
305 |
< |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
305 |
> |
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
306 |
|
} |
307 |
|
try { |
308 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
309 |
|
assertTrue(p1.isTerminated()); |
310 |
< |
} catch(Exception e){ |
310 |
> |
} catch (Exception e){ |
311 |
|
unexpectedException(); |
312 |
|
} |
313 |
|
} |
322 |
|
p1.execute(new SmallRunnable()); |
323 |
|
assertFalse(p1.isTerminating()); |
324 |
|
} finally { |
325 |
< |
try { p1.shutdown(); } catch(SecurityException ok) { return; } |
325 |
> |
try { p1.shutdown(); } catch (SecurityException ok) { return; } |
326 |
|
} |
327 |
|
try { |
328 |
|
assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
329 |
|
assertTrue(p1.isTerminated()); |
330 |
|
assertFalse(p1.isTerminating()); |
331 |
< |
} catch(Exception e){ |
331 |
> |
} catch (Exception e){ |
332 |
|
unexpectedException(); |
333 |
|
} |
334 |
|
} |
340 |
|
BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10); |
341 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); |
342 |
|
FutureTask[] tasks = new FutureTask[5]; |
343 |
< |
for(int i = 0; i < 5; i++){ |
343 |
> |
for (int i = 0; i < 5; i++){ |
344 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
345 |
|
p1.execute(tasks[i]); |
346 |
|
} |
353 |
|
for (int i = 1; i < 5; ++i) |
354 |
|
tasks[i].cancel(true); |
355 |
|
p1.shutdownNow(); |
356 |
< |
} catch(Exception e) { |
356 |
> |
} catch (Exception e) { |
357 |
|
unexpectedException(); |
358 |
|
} finally { |
359 |
|
joinPool(p1); |
367 |
|
BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10); |
368 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); |
369 |
|
FutureTask[] tasks = new FutureTask[5]; |
370 |
< |
for(int i = 0; i < 5; i++){ |
370 |
> |
for (int i = 0; i < 5; i++){ |
371 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
372 |
|
p1.execute(tasks[i]); |
373 |
|
} |
382 |
|
assertTrue(q.contains(tasks[3])); |
383 |
|
assertTrue(p1.remove(tasks[3])); |
384 |
|
assertFalse(q.contains(tasks[3])); |
385 |
< |
} catch(Exception e) { |
385 |
> |
} catch (Exception e) { |
386 |
|
unexpectedException(); |
387 |
|
} finally { |
388 |
|
joinPool(p1); |
395 |
|
public void testPurge() { |
396 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
397 |
|
FutureTask[] tasks = new FutureTask[5]; |
398 |
< |
for(int i = 0; i < 5; i++){ |
398 |
> |
for (int i = 0; i < 5; i++){ |
399 |
|
tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); |
400 |
|
p1.execute(tasks[i]); |
401 |
|
} |
414 |
|
ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10)); |
415 |
|
List l; |
416 |
|
try { |
417 |
< |
for(int i = 0; i < 5; i++) |
417 |
> |
for (int i = 0; i < 5; i++) |
418 |
|
p1.execute(new MediumPossiblyInterruptedRunnable()); |
419 |
|
} |
420 |
|
finally { |
754 |
|
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); |
755 |
|
try { |
756 |
|
|
757 |
< |
for(int i = 0; i < 5; ++i){ |
757 |
> |
for (int i = 0; i < 5; ++i){ |
758 |
|
p.execute(new MediumRunnable()); |
759 |
|
} |
760 |
|
shouldThrow(); |
761 |
< |
} catch(RejectedExecutionException success){} |
761 |
> |
} catch (RejectedExecutionException success){} |
762 |
|
joinPool(p); |
763 |
|
} |
764 |
|
|
771 |
|
try { |
772 |
|
|
773 |
|
TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; |
774 |
< |
for(int i = 0; i < 5; ++i){ |
774 |
> |
for (int i = 0; i < 5; ++i){ |
775 |
|
tasks[i] = new TrackedNoOpRunnable(); |
776 |
|
} |
777 |
|
TrackedLongRunnable mr = new TrackedLongRunnable(); |
778 |
|
p.execute(mr); |
779 |
< |
for(int i = 0; i < 5; ++i){ |
779 |
> |
for (int i = 0; i < 5; ++i){ |
780 |
|
p.execute(tasks[i]); |
781 |
|
} |
782 |
< |
for(int i = 1; i < 5; ++i) { |
782 |
> |
for (int i = 1; i < 5; ++i) { |
783 |
|
assertTrue(tasks[i].done); |
784 |
|
} |
785 |
< |
try { p.shutdownNow(); } catch(SecurityException ok) { return; } |
786 |
< |
} catch(RejectedExecutionException ex){ |
785 |
> |
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
786 |
> |
} catch (RejectedExecutionException ex){ |
787 |
|
unexpectedException(); |
788 |
|
} finally { |
789 |
|
joinPool(p); |
799 |
|
try { |
800 |
|
|
801 |
|
TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; |
802 |
< |
for(int i = 0; i < 5; ++i){ |
802 |
> |
for (int i = 0; i < 5; ++i){ |
803 |
|
tasks[i] = new TrackedNoOpRunnable(); |
804 |
|
} |
805 |
|
p.execute(new TrackedLongRunnable()); |
806 |
< |
for(int i = 0; i < 5; ++i){ |
806 |
> |
for (int i = 0; i < 5; ++i){ |
807 |
|
p.execute(tasks[i]); |
808 |
|
} |
809 |
< |
for(int i = 0; i < 5; ++i){ |
809 |
> |
for (int i = 0; i < 5; ++i){ |
810 |
|
assertFalse(tasks[i].done); |
811 |
|
} |
812 |
< |
try { p.shutdownNow(); } catch(SecurityException ok) { return; } |
813 |
< |
} catch(RejectedExecutionException ex){ |
812 |
> |
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
813 |
> |
} catch (RejectedExecutionException ex){ |
814 |
|
unexpectedException(); |
815 |
|
} finally { |
816 |
|
joinPool(p); |
832 |
|
p.execute(r3); |
833 |
|
assertFalse(p.getQueue().contains(r2)); |
834 |
|
assertTrue(p.getQueue().contains(r3)); |
835 |
< |
try { p.shutdownNow(); } catch(SecurityException ok) { return; } |
836 |
< |
} catch(RejectedExecutionException ex){ |
835 |
> |
try { p.shutdownNow(); } catch (SecurityException ok) { return; } |
836 |
> |
} catch (RejectedExecutionException ex){ |
837 |
|
unexpectedException(); |
838 |
|
} finally { |
839 |
|
joinPool(p); |
846 |
|
public void testRejectedExecutionExceptionOnShutdown() { |
847 |
|
ThreadPoolExecutor tpe = |
848 |
|
new ThreadPoolExecutor(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(1)); |
849 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
849 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
850 |
|
try { |
851 |
|
tpe.execute(new NoOpRunnable()); |
852 |
|
shouldThrow(); |
853 |
< |
} catch(RejectedExecutionException success){} |
853 |
> |
} catch (RejectedExecutionException success){} |
854 |
|
|
855 |
|
joinPool(tpe); |
856 |
|
} |
862 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.CallerRunsPolicy(); |
863 |
|
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h); |
864 |
|
|
865 |
< |
try { p.shutdown(); } catch(SecurityException ok) { return; } |
865 |
> |
try { p.shutdown(); } catch (SecurityException ok) { return; } |
866 |
|
try { |
867 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
868 |
|
p.execute(r); |
869 |
|
assertFalse(r.done); |
870 |
< |
} catch(RejectedExecutionException success){ |
870 |
> |
} catch (RejectedExecutionException success){ |
871 |
|
unexpectedException(); |
872 |
|
} finally { |
873 |
|
joinPool(p); |
881 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardPolicy(); |
882 |
|
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h); |
883 |
|
|
884 |
< |
try { p.shutdown(); } catch(SecurityException ok) { return; } |
884 |
> |
try { p.shutdown(); } catch (SecurityException ok) { return; } |
885 |
|
try { |
886 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
887 |
|
p.execute(r); |
888 |
|
assertFalse(r.done); |
889 |
< |
} catch(RejectedExecutionException success){ |
889 |
> |
} catch (RejectedExecutionException success){ |
890 |
|
unexpectedException(); |
891 |
|
} finally { |
892 |
|
joinPool(p); |
901 |
|
RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy(); |
902 |
|
ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h); |
903 |
|
|
904 |
< |
try { p.shutdown(); } catch(SecurityException ok) { return; } |
904 |
> |
try { p.shutdown(); } catch (SecurityException ok) { return; } |
905 |
|
try { |
906 |
|
TrackedNoOpRunnable r = new TrackedNoOpRunnable(); |
907 |
|
p.execute(r); |
908 |
|
assertFalse(r.done); |
909 |
< |
} catch(RejectedExecutionException success){ |
909 |
> |
} catch (RejectedExecutionException success){ |
910 |
|
unexpectedException(); |
911 |
|
} finally { |
912 |
|
joinPool(p); |
923 |
|
tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
924 |
|
tpe.execute(null); |
925 |
|
shouldThrow(); |
926 |
< |
} catch(NullPointerException success){} |
926 |
> |
} catch (NullPointerException success){} |
927 |
|
|
928 |
|
joinPool(tpe); |
929 |
|
} |
935 |
|
ThreadPoolExecutor tpe = null; |
936 |
|
try { |
937 |
|
tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
938 |
< |
} catch(Exception e){} |
938 |
> |
} catch (Exception e){} |
939 |
|
try { |
940 |
|
tpe.setCorePoolSize(-1); |
941 |
|
shouldThrow(); |
942 |
< |
} catch(IllegalArgumentException success){ |
942 |
> |
} catch (IllegalArgumentException success){ |
943 |
|
} finally { |
944 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
944 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
945 |
|
} |
946 |
|
joinPool(tpe); |
947 |
|
} |
954 |
|
ThreadPoolExecutor tpe = null; |
955 |
|
try { |
956 |
|
tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
957 |
< |
} catch(Exception e){} |
957 |
> |
} catch (Exception e){} |
958 |
|
try { |
959 |
|
tpe.setMaximumPoolSize(1); |
960 |
|
shouldThrow(); |
961 |
< |
} catch(IllegalArgumentException success){ |
961 |
> |
} catch (IllegalArgumentException success){ |
962 |
|
} finally { |
963 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
963 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
964 |
|
} |
965 |
|
joinPool(tpe); |
966 |
|
} |
973 |
|
ThreadPoolExecutor tpe = null; |
974 |
|
try { |
975 |
|
tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
976 |
< |
} catch(Exception e){} |
976 |
> |
} catch (Exception e){} |
977 |
|
try { |
978 |
|
tpe.setMaximumPoolSize(-1); |
979 |
|
shouldThrow(); |
980 |
< |
} catch(IllegalArgumentException success){ |
980 |
> |
} catch (IllegalArgumentException success){ |
981 |
|
} finally { |
982 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
982 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
983 |
|
} |
984 |
|
joinPool(tpe); |
985 |
|
} |
993 |
|
ThreadPoolExecutor tpe = null; |
994 |
|
try { |
995 |
|
tpe = new ThreadPoolExecutor(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
996 |
< |
} catch(Exception e){} |
996 |
> |
} catch (Exception e){} |
997 |
|
|
998 |
|
try { |
999 |
|
tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS); |
1000 |
|
shouldThrow(); |
1001 |
< |
} catch(IllegalArgumentException success){ |
1001 |
> |
} catch (IllegalArgumentException success){ |
1002 |
|
} finally { |
1003 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1003 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1004 |
|
} |
1005 |
|
joinPool(tpe); |
1006 |
|
} |
1010 |
|
*/ |
1011 |
|
public void testTerminated() { |
1012 |
|
ExtendedTPE tpe = new ExtendedTPE(); |
1013 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1013 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1014 |
|
assertTrue(tpe.terminatedCalled); |
1015 |
|
joinPool(tpe); |
1016 |
|
} |
1027 |
|
assertTrue(r.done); |
1028 |
|
assertTrue(tpe.beforeCalled); |
1029 |
|
assertTrue(tpe.afterCalled); |
1030 |
< |
try { tpe.shutdown(); } catch(SecurityException ok) { return; } |
1030 |
> |
try { tpe.shutdown(); } catch (SecurityException ok) { return; } |
1031 |
|
} |
1032 |
< |
catch(Exception ex) { |
1032 |
> |
catch (Exception ex) { |
1033 |
|
unexpectedException(); |
1034 |
|
} finally { |
1035 |
|
joinPool(tpe); |
1108 |
|
try { |
1109 |
|
e.invokeAny(null); |
1110 |
|
} catch (NullPointerException success) { |
1111 |
< |
} catch(Exception ex) { |
1111 |
> |
} catch (Exception ex) { |
1112 |
|
unexpectedException(); |
1113 |
|
} finally { |
1114 |
|
joinPool(e); |
1123 |
|
try { |
1124 |
|
e.invokeAny(new ArrayList<Callable<String>>()); |
1125 |
|
} catch (IllegalArgumentException success) { |
1126 |
< |
} catch(Exception ex) { |
1126 |
> |
} catch (Exception ex) { |
1127 |
|
unexpectedException(); |
1128 |
|
} finally { |
1129 |
|
joinPool(e); |
1141 |
|
l.add(null); |
1142 |
|
e.invokeAny(l); |
1143 |
|
} catch (NullPointerException success) { |
1144 |
< |
} catch(Exception ex) { |
1144 |
> |
} catch (Exception ex) { |
1145 |
|
unexpectedException(); |
1146 |
|
} finally { |
1147 |
|
joinPool(e); |
1158 |
|
l.add(new NPETask()); |
1159 |
|
e.invokeAny(l); |
1160 |
|
} catch (ExecutionException success) { |
1161 |
< |
} catch(Exception ex) { |
1161 |
> |
} catch (Exception ex) { |
1162 |
|
unexpectedException(); |
1163 |
|
} finally { |
1164 |
|
joinPool(e); |
1177 |
|
String result = e.invokeAny(l); |
1178 |
|
assertSame(TEST_STRING, result); |
1179 |
|
} catch (ExecutionException success) { |
1180 |
< |
} catch(Exception ex) { |
1180 |
> |
} catch (Exception ex) { |
1181 |
|
unexpectedException(); |
1182 |
|
} finally { |
1183 |
|
joinPool(e); |
1192 |
|
try { |
1193 |
|
e.invokeAll(null); |
1194 |
|
} catch (NullPointerException success) { |
1195 |
< |
} catch(Exception ex) { |
1195 |
> |
} catch (Exception ex) { |
1196 |
|
unexpectedException(); |
1197 |
|
} finally { |
1198 |
|
joinPool(e); |
1207 |
|
try { |
1208 |
|
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>()); |
1209 |
|
assertTrue(r.isEmpty()); |
1210 |
< |
} catch(Exception ex) { |
1210 |
> |
} catch (Exception ex) { |
1211 |
|
unexpectedException(); |
1212 |
|
} finally { |
1213 |
|
joinPool(e); |
1225 |
|
l.add(null); |
1226 |
|
e.invokeAll(l); |
1227 |
|
} catch (NullPointerException success) { |
1228 |
< |
} catch(Exception ex) { |
1228 |
> |
} catch (Exception ex) { |
1229 |
|
unexpectedException(); |
1230 |
|
} finally { |
1231 |
|
joinPool(e); |
1244 |
|
assertEquals(1, result.size()); |
1245 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1246 |
|
it.next().get(); |
1247 |
< |
} catch(ExecutionException success) { |
1248 |
< |
} catch(Exception ex) { |
1247 |
> |
} catch (ExecutionException success) { |
1248 |
> |
} catch (Exception ex) { |
1249 |
|
unexpectedException(); |
1250 |
|
} finally { |
1251 |
|
joinPool(e); |
1266 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1267 |
|
assertSame(TEST_STRING, it.next().get()); |
1268 |
|
} catch (ExecutionException success) { |
1269 |
< |
} catch(Exception ex) { |
1269 |
> |
} catch (Exception ex) { |
1270 |
|
unexpectedException(); |
1271 |
|
} finally { |
1272 |
|
joinPool(e); |
1283 |
|
try { |
1284 |
|
e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1285 |
|
} catch (NullPointerException success) { |
1286 |
< |
} catch(Exception ex) { |
1286 |
> |
} catch (Exception ex) { |
1287 |
|
unexpectedException(); |
1288 |
|
} finally { |
1289 |
|
joinPool(e); |
1300 |
|
l.add(new StringTask()); |
1301 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, null); |
1302 |
|
} catch (NullPointerException success) { |
1303 |
< |
} catch(Exception ex) { |
1303 |
> |
} catch (Exception ex) { |
1304 |
|
unexpectedException(); |
1305 |
|
} finally { |
1306 |
|
joinPool(e); |
1315 |
|
try { |
1316 |
|
e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1317 |
|
} catch (IllegalArgumentException success) { |
1318 |
< |
} catch(Exception ex) { |
1318 |
> |
} catch (Exception ex) { |
1319 |
|
unexpectedException(); |
1320 |
|
} finally { |
1321 |
|
joinPool(e); |
1333 |
|
l.add(null); |
1334 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1335 |
|
} catch (NullPointerException success) { |
1336 |
< |
} catch(Exception ex) { |
1336 |
> |
} catch (Exception ex) { |
1337 |
|
ex.printStackTrace(); |
1338 |
|
unexpectedException(); |
1339 |
|
} finally { |
1350 |
|
ArrayList<Callable<String>> l = new ArrayList<Callable<String>>(); |
1351 |
|
l.add(new NPETask()); |
1352 |
|
e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1353 |
< |
} catch(ExecutionException success) { |
1354 |
< |
} catch(Exception ex) { |
1353 |
> |
} catch (ExecutionException success) { |
1354 |
> |
} catch (Exception ex) { |
1355 |
|
unexpectedException(); |
1356 |
|
} finally { |
1357 |
|
joinPool(e); |
1370 |
|
String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1371 |
|
assertSame(TEST_STRING, result); |
1372 |
|
} catch (ExecutionException success) { |
1373 |
< |
} catch(Exception ex) { |
1373 |
> |
} catch (Exception ex) { |
1374 |
|
unexpectedException(); |
1375 |
|
} finally { |
1376 |
|
joinPool(e); |
1385 |
|
try { |
1386 |
|
e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1387 |
|
} catch (NullPointerException success) { |
1388 |
< |
} catch(Exception ex) { |
1388 |
> |
} catch (Exception ex) { |
1389 |
|
unexpectedException(); |
1390 |
|
} finally { |
1391 |
|
joinPool(e); |
1402 |
|
l.add(new StringTask()); |
1403 |
|
e.invokeAll(l, MEDIUM_DELAY_MS, null); |
1404 |
|
} catch (NullPointerException success) { |
1405 |
< |
} catch(Exception ex) { |
1405 |
> |
} catch (Exception ex) { |
1406 |
|
unexpectedException(); |
1407 |
|
} finally { |
1408 |
|
joinPool(e); |
1417 |
|
try { |
1418 |
|
List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1419 |
|
assertTrue(r.isEmpty()); |
1420 |
< |
} catch(Exception ex) { |
1420 |
> |
} catch (Exception ex) { |
1421 |
|
unexpectedException(); |
1422 |
|
} finally { |
1423 |
|
joinPool(e); |
1435 |
|
l.add(null); |
1436 |
|
e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
1437 |
|
} catch (NullPointerException success) { |
1438 |
< |
} catch(Exception ex) { |
1438 |
> |
} catch (Exception ex) { |
1439 |
|
unexpectedException(); |
1440 |
|
} finally { |
1441 |
|
joinPool(e); |
1454 |
|
assertEquals(1, result.size()); |
1455 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1456 |
|
it.next().get(); |
1457 |
< |
} catch(ExecutionException success) { |
1458 |
< |
} catch(Exception ex) { |
1457 |
> |
} catch (ExecutionException success) { |
1458 |
> |
} catch (Exception ex) { |
1459 |
|
unexpectedException(); |
1460 |
|
} finally { |
1461 |
|
joinPool(e); |
1476 |
|
for (Iterator<Future<String>> it = result.iterator(); it.hasNext();) |
1477 |
|
assertSame(TEST_STRING, it.next().get()); |
1478 |
|
} catch (ExecutionException success) { |
1479 |
< |
} catch(Exception ex) { |
1479 |
> |
} catch (Exception ex) { |
1480 |
|
unexpectedException(); |
1481 |
|
} finally { |
1482 |
|
joinPool(e); |
1504 |
|
assertTrue(f3.isDone()); |
1505 |
|
assertFalse(f1.isCancelled()); |
1506 |
|
assertTrue(f2.isCancelled()); |
1507 |
< |
} catch(Exception ex) { |
1507 |
> |
} catch (Exception ex) { |
1508 |
|
unexpectedException(); |
1509 |
|
} finally { |
1510 |
|
joinPool(e); |
1523 |
|
e.execute(new NoOpRunnable()); |
1524 |
|
} |
1525 |
|
Thread.sleep(LONG_DELAY_MS); |
1526 |
< |
} catch(Exception ex) { |
1526 |
> |
} catch (Exception ex) { |
1527 |
|
unexpectedException(); |
1528 |
|
} finally { |
1529 |
|
joinPool(e); |
1549 |
|
try { |
1550 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
1551 |
|
assertEquals(0, tpe.getPoolSize()); |
1552 |
< |
} catch(InterruptedException e){ |
1552 |
> |
} catch (InterruptedException e){ |
1553 |
|
unexpectedException(); |
1554 |
|
} finally { |
1555 |
|
joinPool(tpe); |
1566 |
|
try { |
1567 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
1568 |
|
assertTrue(tpe.getPoolSize() >= 1); |
1569 |
< |
} catch(InterruptedException e){ |
1569 |
> |
} catch (InterruptedException e){ |
1570 |
|
unexpectedException(); |
1571 |
|
} finally { |
1572 |
|
joinPool(tpe); |
1600 |
|
} |
1601 |
|
Thread.sleep(5000); // enough time to run all tasks |
1602 |
|
assertEquals(nRun.get(), nTasks); |
1603 |
< |
} catch(Exception ex) { |
1603 |
> |
} catch (Exception ex) { |
1604 |
|
ex.printStackTrace(); |
1605 |
|
unexpectedException(); |
1606 |
|
} finally { |