59
59
* <h2>Preemptive Timeouts</h2>
60
60
*
61
61
* <p>The various {@code assertTimeoutPreemptively()} methods in this class
62
- * execute the provided {@code executable} or {@code supplier} in a different
63
- * thread than that of the calling code. This behavior can lead to undesirable
64
- * side effects if the code that is executed within the {@code executable} or
65
- * {@code supplier} relies on {@link ThreadLocal} storage.
62
+ * execute the provided callback ({@code executable} or {@code supplier}) in a
63
+ * different thread than that of the calling code. If the timeout is exceeded,
64
+ * an attempt will be made to preemptively abort execution of the callback by
65
+ * {@linkplain Thread#interrupt() interrupting} the callback's thread. If the
66
+ * callback's thread does not return when interrupted, the thread will continue
67
+ * to run in the background after the {@code assertTimeoutPreemptively()} method
68
+ * has returned.
66
69
*
67
- * <p>One common example of this is the transactional testing support in the Spring
68
- * Framework. Specifically, Spring's testing support binds transaction state to
69
- * the current thread (via a {@code ThreadLocal}) before a test method is invoked.
70
- * Consequently, if an {@code executable} or {@code supplier} provided to
71
- * {@code assertTimeoutPreemptively()} invokes Spring-managed components that
72
- * participate in transactions, any actions taken by those components will not be
73
- * rolled back with the test-managed transaction. On the contrary, such actions
74
- * will be committed to the persistent store (e.g., relational database) even
75
- * though the test-managed transaction is rolled back.
76
- *
77
- * <p>Similar side effects may be encountered with other frameworks that rely on
70
+ * <p>Furthermore, the behavior of {@code assertTimeoutPreemptively()} methods
71
+ * can lead to undesirable side effects if the code that is executed within the
72
+ * callback relies on {@link ThreadLocal} storage. One common example of this is
73
+ * the transactional testing support in the Spring Framework. Specifically, Spring's
74
+ * testing support binds transaction state to the current thread (via a
75
+ * {@code ThreadLocal}) before a test method is invoked. Consequently, if a
76
+ * callback provided to {@code assertTimeoutPreemptively()} invokes Spring-managed
77
+ * components that participate in transactions, any actions taken by those
78
+ * components will not be rolled back with the test-managed transaction. On the
79
+ * contrary, such actions will be committed to the persistent store (e.g.,
80
+ * relational database) even though the test-managed transaction is rolled back.
81
+ * Similar side effects may be encountered with other frameworks that rely on
78
82
* {@code ThreadLocal} storage.
79
83
*
80
84
* <h2>Extensibility</h2>
@@ -3410,11 +3414,8 @@ public static <T> T assertTimeout(Duration timeout, ThrowingSupplier<T> supplier
3410
3414
* <em>Assert</em> that execution of the supplied {@code executable}
3411
3415
* completes before the given {@code timeout} is exceeded.
3412
3416
*
3413
- * <p>Note: the {@code executable} will be executed in a different thread than
3414
- * that of the calling code. Furthermore, execution of the {@code executable} will
3415
- * be preemptively aborted if the timeout is exceeded. See the
3416
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3417
- * Javadoc for a discussion of possible undesirable side effects.
3417
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3418
+ * class-level Javadoc for further details.
3418
3419
*
3419
3420
* @see #assertTimeoutPreemptively(Duration, Executable, String)
3420
3421
* @see #assertTimeoutPreemptively(Duration, Executable, Supplier)
@@ -3431,11 +3432,8 @@ public static void assertTimeoutPreemptively(Duration timeout, Executable execut
3431
3432
* <em>Assert</em> that execution of the supplied {@code executable}
3432
3433
* completes before the given {@code timeout} is exceeded.
3433
3434
*
3434
- * <p>Note: the {@code executable} will be executed in a different thread than
3435
- * that of the calling code. Furthermore, execution of the {@code executable} will
3436
- * be preemptively aborted if the timeout is exceeded. See the
3437
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3438
- * Javadoc for a discussion of possible undesirable side effects.
3435
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3436
+ * class-level Javadoc for further details.
3439
3437
*
3440
3438
* <p>Fails with the supplied failure {@code message}.
3441
3439
*
@@ -3454,11 +3452,8 @@ public static void assertTimeoutPreemptively(Duration timeout, Executable execut
3454
3452
* <em>Assert</em> that execution of the supplied {@code executable}
3455
3453
* completes before the given {@code timeout} is exceeded.
3456
3454
*
3457
- * <p>Note: the {@code executable} will be executed in a different thread than
3458
- * that of the calling code. Furthermore, execution of the {@code executable} will
3459
- * be preemptively aborted if the timeout is exceeded. See the
3460
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3461
- * Javadoc for a discussion of possible undesirable side effects.
3455
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3456
+ * class-level Javadoc for further details.
3462
3457
*
3463
3458
* <p>If necessary, the failure message will be retrieved lazily from the
3464
3459
* supplied {@code messageSupplier}.
@@ -3481,13 +3476,10 @@ public static void assertTimeoutPreemptively(Duration timeout, Executable execut
3481
3476
* <em>Assert</em> that execution of the supplied {@code supplier}
3482
3477
* completes before the given {@code timeout} is exceeded.
3483
3478
*
3484
- * <p>If the assertion passes then the {@code supplier}'s result is returned.
3479
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3480
+ * class-level Javadoc for further details.
3485
3481
*
3486
- * <p>Note: the {@code supplier} will be executed in a different thread than
3487
- * that of the calling code. Furthermore, execution of the {@code supplier} will
3488
- * be preemptively aborted if the timeout is exceeded. See the
3489
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3490
- * Javadoc for a discussion of possible undesirable side effects.
3482
+ * <p>If the assertion passes then the {@code supplier}'s result is returned.
3491
3483
*
3492
3484
* @see #assertTimeoutPreemptively(Duration, Executable)
3493
3485
* @see #assertTimeoutPreemptively(Duration, Executable, String)
@@ -3504,13 +3496,10 @@ public static <T> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier
3504
3496
* <em>Assert</em> that execution of the supplied {@code supplier}
3505
3497
* completes before the given {@code timeout} is exceeded.
3506
3498
*
3507
- * <p>If the assertion passes then the {@code supplier}'s result is returned.
3499
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3500
+ * class-level Javadoc for further details.
3508
3501
*
3509
- * <p>Note: the {@code supplier} will be executed in a different thread than
3510
- * that of the calling code. Furthermore, execution of the {@code supplier} will
3511
- * be preemptively aborted if the timeout is exceeded. See the
3512
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3513
- * Javadoc for a discussion of possible undesirable side effects.
3502
+ * <p>If the assertion passes then the {@code supplier}'s result is returned.
3514
3503
*
3515
3504
* <p>Fails with the supplied failure {@code message}.
3516
3505
*
@@ -3529,13 +3518,10 @@ public static <T> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier
3529
3518
* <em>Assert</em> that execution of the supplied {@code supplier}
3530
3519
* completes before the given {@code timeout} is exceeded.
3531
3520
*
3532
- * <p>If the assertion passes then the {@code supplier}'s result is returned.
3521
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3522
+ * class-level Javadoc for further details.
3533
3523
*
3534
- * <p>Note: the {@code supplier} will be executed in a different thread than
3535
- * that of the calling code. Furthermore, execution of the {@code supplier} will
3536
- * be preemptively aborted if the timeout is exceeded. See the
3537
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3538
- * Javadoc for a discussion of possible undesirable side effects.
3524
+ * <p>If the assertion passes then the {@code supplier}'s result is returned.
3539
3525
*
3540
3526
* <p>If necessary, the failure message will be retrieved lazily from the
3541
3527
* supplied {@code messageSupplier}.
@@ -3556,18 +3542,15 @@ public static <T> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier
3556
3542
* <em>Assert</em> that execution of the supplied {@code supplier}
3557
3543
* completes before the given {@code timeout} is exceeded.
3558
3544
*
3545
+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3546
+ * class-level Javadoc for further details.
3547
+ *
3559
3548
* <p>If the assertion passes then the {@code supplier}'s result is returned.
3560
3549
*
3561
3550
* <p>In the case the assertion does not pass, the supplied
3562
3551
* {@link TimeoutFailureFactory} is invoked to create an exception which is
3563
3552
* then thrown.
3564
3553
*
3565
- * <p>Note: the {@code supplier} will be executed in a different thread than
3566
- * that of the calling code. Furthermore, execution of the {@code supplier} will
3567
- * be preemptively aborted if the timeout is exceeded. See the
3568
- * {@linkplain Assertions Preemptive Timeouts} section of the class-level
3569
- * Javadoc for a discussion of possible undesirable side effects.
3570
- *
3571
3554
* <p>If necessary, the failure message will be retrieved lazily from the
3572
3555
* supplied {@code messageSupplier}.
3573
3556
*
0 commit comments