286 |
|
|
287 |
|
/** |
288 |
|
* threadFail with message "should throw exception" |
289 |
< |
*/ |
289 |
> |
*/ |
290 |
|
public void threadShouldThrow() { |
291 |
|
try { |
292 |
|
threadFailed = true; |
321 |
|
try { |
322 |
|
exec.shutdown(); |
323 |
|
assertTrue(exec.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); |
324 |
< |
} catch(SecurityException ok) { |
324 |
> |
} catch (SecurityException ok) { |
325 |
|
// Allowed in case test doesn't have privs |
326 |
< |
} catch(InterruptedException ie) { |
326 |
> |
} catch (InterruptedException ie) { |
327 |
|
fail("Unexpected exception"); |
328 |
|
} |
329 |
|
} |
421 |
|
try { |
422 |
|
Thread.sleep(SHORT_DELAY_MS); |
423 |
|
} |
424 |
< |
catch(Exception e) { |
424 |
> |
catch (Exception e) { |
425 |
|
threadUnexpectedException(e); |
426 |
|
} |
427 |
|
} |
433 |
|
Thread.sleep(SHORT_DELAY_MS); |
434 |
|
threadShouldThrow(); |
435 |
|
} |
436 |
< |
catch(InterruptedException success) { |
436 |
> |
catch (InterruptedException success) { |
437 |
|
} |
438 |
|
} |
439 |
|
} |
443 |
|
try { |
444 |
|
Thread.sleep(SMALL_DELAY_MS); |
445 |
|
} |
446 |
< |
catch(Exception e) { |
446 |
> |
catch (Exception e) { |
447 |
|
threadUnexpectedException(e); |
448 |
|
} |
449 |
|
} |
454 |
|
try { |
455 |
|
Thread.sleep(SMALL_DELAY_MS); |
456 |
|
} |
457 |
< |
catch(Exception e) { |
457 |
> |
catch (Exception e) { |
458 |
|
} |
459 |
|
} |
460 |
|
} |
464 |
|
try { |
465 |
|
Thread.sleep(SMALL_DELAY_MS); |
466 |
|
} |
467 |
< |
catch(Exception e) { |
467 |
> |
catch (Exception e) { |
468 |
|
threadUnexpectedException(e); |
469 |
|
} |
470 |
|
return Boolean.TRUE; |
477 |
|
Thread.sleep(SMALL_DELAY_MS); |
478 |
|
threadShouldThrow(); |
479 |
|
} |
480 |
< |
catch(InterruptedException success) { |
480 |
> |
catch (InterruptedException success) { |
481 |
|
} |
482 |
|
} |
483 |
|
} |
488 |
|
try { |
489 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
490 |
|
} |
491 |
< |
catch(Exception e) { |
491 |
> |
catch (Exception e) { |
492 |
|
threadUnexpectedException(e); |
493 |
|
} |
494 |
|
} |
500 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
501 |
|
threadShouldThrow(); |
502 |
|
} |
503 |
< |
catch(InterruptedException success) { |
503 |
> |
catch (InterruptedException success) { |
504 |
|
} |
505 |
|
} |
506 |
|
} |
510 |
|
try { |
511 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
512 |
|
} |
513 |
< |
catch(InterruptedException success) { |
513 |
> |
catch (InterruptedException success) { |
514 |
|
} |
515 |
|
} |
516 |
|
} |
520 |
|
try { |
521 |
|
Thread.sleep(LONG_DELAY_MS); |
522 |
|
} |
523 |
< |
catch(InterruptedException success) { |
523 |
> |
catch (InterruptedException success) { |
524 |
|
} |
525 |
|
} |
526 |
|
} |
528 |
|
/** |
529 |
|
* For use as ThreadFactory in constructors |
530 |
|
*/ |
531 |
< |
static class SimpleThreadFactory implements ThreadFactory{ |
532 |
< |
public Thread newThread(Runnable r){ |
531 |
> |
static class SimpleThreadFactory implements ThreadFactory { |
532 |
> |
public Thread newThread(Runnable r) { |
533 |
|
return new Thread(r); |
534 |
|
} |
535 |
|
} |
540 |
|
try { |
541 |
|
Thread.sleep(SMALL_DELAY_MS); |
542 |
|
done = true; |
543 |
< |
} catch(Exception e){ |
543 |
> |
} catch (Exception e) { |
544 |
|
} |
545 |
|
} |
546 |
|
} |
551 |
|
try { |
552 |
|
Thread.sleep(MEDIUM_DELAY_MS); |
553 |
|
done = true; |
554 |
< |
} catch(Exception e){ |
554 |
> |
} catch (Exception e) { |
555 |
|
} |
556 |
|
} |
557 |
|
} |
562 |
|
try { |
563 |
|
Thread.sleep(LONG_DELAY_MS); |
564 |
|
done = true; |
565 |
< |
} catch(Exception e){ |
565 |
> |
} catch (Exception e) { |
566 |
|
} |
567 |
|
} |
568 |
|
} |
580 |
|
try { |
581 |
|
Thread.sleep(SMALL_DELAY_MS); |
582 |
|
done = true; |
583 |
< |
} catch(Exception e){ |
583 |
> |
} catch (Exception e) { |
584 |
|
} |
585 |
|
return Boolean.TRUE; |
586 |
|
} |
590 |
|
/** |
591 |
|
* For use as RejectedExecutionHandler in constructors |
592 |
|
*/ |
593 |
< |
static class NoOpREHandler implements RejectedExecutionHandler{ |
593 |
> |
static class NoOpREHandler implements RejectedExecutionHandler { |
594 |
|
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor){} |
595 |
|
} |
596 |
|
|