RFR: 8314515: java/util/concurrent/SynchronousQueue/Fairness.java failed with "Error: fair=false i=8 j=0"
Martin Buchholz
martin at openjdk.org
Sat Aug 19 02:51:44 UTC 2023
On Fri, 18 Aug 2023 08:18:24 GMT, Viktor Klang <duke at openjdk.org> 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
More information about the core-libs-dev
mailing list