RFR: 8369306: Implement invokeAndWait and finishTerminating on headless platform [v3]
Johan Vos
jvos at openjdk.org
Sat Oct 11 08:55:18 UTC 2025
On Fri, 10 Oct 2025 12:46:08 GMT, Jose Pereda <jpereda at openjdk.org> wrote:
>> tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplication2Test.java line 49:
>>
>>> 47: Platform.runLater(Platform::exit);
>>> 48: });
>>> 49: Util.sleep(10);
>>
>> Is 10msec enough?
>
> I'm testing on an M1, but you are right, on different environments it could take longer.
>
> I've added now an exit latch from `PlatformImplShim.test_getPlatformExitLatch()`, so we wait whatever is needed until `PlatformImpl.tkExit()` finishes, and then those 10 ms should be more than enough (but we still need to wait a couple of ms nonetheless until the JavaFX thread is fully gone).
In general, I'm not a fan of adding hard-numbered sleep times. Either the expected events are delivered, or they are not (yet). The hard sleep pattern leads to either slowdowns or to failing tests on slow environments.
Using CountdownLatches and deterministic flows is much better for testing, imho.
Since the Util.sleep is widely used in other system tests, I'm ok with using it here as well -- but I still think it is a dangerous approach.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2422628813
More information about the openjfx-dev
mailing list