274 |
|
new ThreadPoolExecutor(1, 2, |
275 |
|
LONG_DELAY_MS, MILLISECONDS, |
276 |
|
new ArrayBlockingQueue<Runnable>(10)); |
277 |
< |
try { |
278 |
< |
p.setThreadFactory(null); |
279 |
< |
shouldThrow(); |
280 |
< |
} catch (NullPointerException success) { |
281 |
< |
} finally { |
282 |
< |
joinPool(p); |
277 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
278 |
> |
try { |
279 |
> |
p.setThreadFactory(null); |
280 |
> |
shouldThrow(); |
281 |
> |
} catch (NullPointerException success) {} |
282 |
|
} |
283 |
|
} |
284 |
|
|
286 |
|
* getRejectedExecutionHandler returns handler in constructor if not set |
287 |
|
*/ |
288 |
|
public void testGetRejectedExecutionHandler() { |
289 |
< |
final RejectedExecutionHandler h = new NoOpREHandler(); |
289 |
> |
final RejectedExecutionHandler handler = new NoOpREHandler(); |
290 |
|
final ThreadPoolExecutor p = |
291 |
|
new ThreadPoolExecutor(1, 2, |
292 |
|
LONG_DELAY_MS, MILLISECONDS, |
293 |
|
new ArrayBlockingQueue<Runnable>(10), |
294 |
< |
h); |
295 |
< |
assertSame(h, p.getRejectedExecutionHandler()); |
296 |
< |
joinPool(p); |
294 |
> |
handler); |
295 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
296 |
> |
assertSame(handler, p.getRejectedExecutionHandler()); |
297 |
> |
} |
298 |
|
} |
299 |
|
|
300 |
|
/** |
306 |
|
new ThreadPoolExecutor(1, 2, |
307 |
|
LONG_DELAY_MS, MILLISECONDS, |
308 |
|
new ArrayBlockingQueue<Runnable>(10)); |
309 |
< |
RejectedExecutionHandler h = new NoOpREHandler(); |
310 |
< |
p.setRejectedExecutionHandler(h); |
311 |
< |
assertSame(h, p.getRejectedExecutionHandler()); |
312 |
< |
joinPool(p); |
309 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
310 |
> |
RejectedExecutionHandler handler = new NoOpREHandler(); |
311 |
> |
p.setRejectedExecutionHandler(handler); |
312 |
> |
assertSame(handler, p.getRejectedExecutionHandler()); |
313 |
> |
} |
314 |
|
} |
315 |
|
|
316 |
|
/** |
321 |
|
new ThreadPoolExecutor(1, 2, |
322 |
|
LONG_DELAY_MS, MILLISECONDS, |
323 |
|
new ArrayBlockingQueue<Runnable>(10)); |
324 |
< |
try { |
325 |
< |
p.setRejectedExecutionHandler(null); |
326 |
< |
shouldThrow(); |
327 |
< |
} catch (NullPointerException success) { |
328 |
< |
} finally { |
328 |
< |
joinPool(p); |
324 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
325 |
> |
try { |
326 |
> |
p.setRejectedExecutionHandler(null); |
327 |
> |
shouldThrow(); |
328 |
> |
} catch (NullPointerException success) {} |
329 |
|
} |
330 |
|
} |
331 |
|
|