5959 * <h2>Preemptive Timeouts</h2>
6060 *
6161 * <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.
6669 *
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
7882 * {@code ThreadLocal} storage.
7983 *
8084 * <h2>Extensibility</h2>
@@ -3410,11 +3414,8 @@ public static <T> T assertTimeout(Duration timeout, ThrowingSupplier<T> supplier
34103414 * <em>Assert</em> that execution of the supplied {@code executable}
34113415 * completes before the given {@code timeout} is exceeded.
34123416 *
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.
34183419 *
34193420 * @see #assertTimeoutPreemptively(Duration, Executable, String)
34203421 * @see #assertTimeoutPreemptively(Duration, Executable, Supplier)
@@ -3431,11 +3432,8 @@ public static void assertTimeoutPreemptively(Duration timeout, Executable execut
34313432 * <em>Assert</em> that execution of the supplied {@code executable}
34323433 * completes before the given {@code timeout} is exceeded.
34333434 *
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.
34393437 *
34403438 * <p>Fails with the supplied failure {@code message}.
34413439 *
@@ -3454,11 +3452,8 @@ public static void assertTimeoutPreemptively(Duration timeout, Executable execut
34543452 * <em>Assert</em> that execution of the supplied {@code executable}
34553453 * completes before the given {@code timeout} is exceeded.
34563454 *
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.
34623457 *
34633458 * <p>If necessary, the failure message will be retrieved lazily from the
34643459 * supplied {@code messageSupplier}.
@@ -3481,13 +3476,10 @@ public static void assertTimeoutPreemptively(Duration timeout, Executable execut
34813476 * <em>Assert</em> that execution of the supplied {@code supplier}
34823477 * completes before the given {@code timeout} is exceeded.
34833478 *
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.
34853481 *
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.
34913483 *
34923484 * @see #assertTimeoutPreemptively(Duration, Executable)
34933485 * @see #assertTimeoutPreemptively(Duration, Executable, String)
@@ -3504,13 +3496,10 @@ public static <T> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier
35043496 * <em>Assert</em> that execution of the supplied {@code supplier}
35053497 * completes before the given {@code timeout} is exceeded.
35063498 *
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.
35083501 *
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.
35143503 *
35153504 * <p>Fails with the supplied failure {@code message}.
35163505 *
@@ -3529,13 +3518,10 @@ public static <T> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier
35293518 * <em>Assert</em> that execution of the supplied {@code supplier}
35303519 * completes before the given {@code timeout} is exceeded.
35313520 *
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.
35333523 *
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.
35393525 *
35403526 * <p>If necessary, the failure message will be retrieved lazily from the
35413527 * supplied {@code messageSupplier}.
@@ -3556,18 +3542,15 @@ public static <T> T assertTimeoutPreemptively(Duration timeout, ThrowingSupplier
35563542 * <em>Assert</em> that execution of the supplied {@code supplier}
35573543 * completes before the given {@code timeout} is exceeded.
35583544 *
3545+ * <p>See the {@linkplain Assertions Preemptive Timeouts} section of the
3546+ * class-level Javadoc for further details.
3547+ *
35593548 * <p>If the assertion passes then the {@code supplier}'s result is returned.
35603549 *
35613550 * <p>In the case the assertion does not pass, the supplied
35623551 * {@link TimeoutFailureFactory} is invoked to create an exception which is
35633552 * then thrown.
35643553 *
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- *
35713554 * <p>If necessary, the failure message will be retrieved lazily from the
35723555 * supplied {@code messageSupplier}.
35733556 *
0 commit comments