On Fri, 18 Aug 2023 08:18:24 GMT, Viktor Klang <[email protected]> wrote:
>> The usual tiny improvements, with no guarantee that the intermittent test
>> failure is actually fixed.
>
> test/jdk/java/util/concurrent/SynchronousQueue/Fairness.java line 70:
>
>> 68: fair, i, threadCount, j));
>> 69: }
>> 70: for (Thread t : ts) t.join();
>
> @Martin-Buchholz Makes a lot of sense to make sure that all threads have
> terminated before exiting the test 👍
There's a lot of infrastructure in JSR166TestCase.java to address this. Some
of it could be librarified for use by other openjdk tests.
* <li>All code not running in the main test thread (manually spawned threads
* or the common fork join pool) must be checked for failure (and completion!).
* Mechanisms that can be used to ensure this are:
* <ol>
* <li>Signalling via a synchronizer like AtomicInteger or CountDownLatch
* that the task completed normally, which is checked before returning from
* the test method in the main thread.
* <li>Using the forms {@link #threadFail}, {@link #threadAssertTrue},
* or {@link #threadAssertNull}, (not {@code fail}, {@code assertTrue}, etc.)
* Only the most typically used JUnit assertion methods are defined
* this way, but enough to live with.
* <li>Recording failure explicitly using {@link #threadUnexpectedException}
* or {@link #threadRecordFailure}.
* <li>Using a wrapper like CheckedRunnable that uses one the mechanisms
above.
* </ol>
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15337#discussion_r1299029889