550 |
|
} |
551 |
|
} |
552 |
|
|
553 |
+ |
static class CountingRejectingExecutor implements Executor { |
554 |
+ |
final RejectedExecutionException ex = new RejectedExecutionException(); |
555 |
+ |
final AtomicInteger count = new AtomicInteger(0); |
556 |
+ |
public void execute(Runnable r) { |
557 |
+ |
count.getAndIncrement(); |
558 |
+ |
throw ex; |
559 |
+ |
} |
560 |
+ |
} |
561 |
+ |
|
562 |
|
// Used for explicit executor tests |
563 |
|
static final class ThreadExecutor implements Executor { |
564 |
|
final AtomicInteger count = new AtomicInteger(0); |
1243 |
|
r.assertInvoked(); |
1244 |
|
}} |
1245 |
|
|
1246 |
+ |
public void testRunAsync_rejectingExecutor() { |
1247 |
+ |
CountingRejectingExecutor e = new CountingRejectingExecutor(); |
1248 |
+ |
try { |
1249 |
+ |
CompletableFuture.runAsync(() -> {}, e); |
1250 |
+ |
shouldThrow(); |
1251 |
+ |
} catch (Throwable t) { |
1252 |
+ |
assertSame(e.ex, t); |
1253 |
+ |
} |
1254 |
+ |
|
1255 |
+ |
assertEquals(1, e.count.get()); |
1256 |
+ |
} |
1257 |
+ |
|
1258 |
|
/** |
1259 |
|
* supplyAsync completes with result of supplier |
1260 |
|
*/ |
1289 |
|
r.assertInvoked(); |
1290 |
|
}} |
1291 |
|
|
1292 |
+ |
public void testSupplyAsync_rejectingExecutor() { |
1293 |
+ |
CountingRejectingExecutor e = new CountingRejectingExecutor(); |
1294 |
+ |
try { |
1295 |
+ |
CompletableFuture.supplyAsync(() -> null, e); |
1296 |
+ |
shouldThrow(); |
1297 |
+ |
} catch (Throwable t) { |
1298 |
+ |
assertSame(e.ex, t); |
1299 |
+ |
} |
1300 |
+ |
|
1301 |
+ |
assertEquals(1, e.count.get()); |
1302 |
+ |
} |
1303 |
+ |
|
1304 |
|
// seq completion methods |
1305 |
|
|
1306 |
|
/** |
3350 |
|
assertEquals(0, exec.count.get()); |
3351 |
|
} |
3352 |
|
|
3320 |
– |
static class CountingRejectingExecutor implements Executor { |
3321 |
– |
final RejectedExecutionException ex = new RejectedExecutionException(); |
3322 |
– |
final AtomicInteger count = new AtomicInteger(0); |
3323 |
– |
public void execute(Runnable r) { |
3324 |
– |
count.getAndIncrement(); |
3325 |
– |
throw ex; |
3326 |
– |
} |
3327 |
– |
} |
3328 |
– |
|
3353 |
|
/** |
3354 |
|
* Test submissions to an executor that rejects all tasks. |
3355 |
|
*/ |