RFR: modify VirtualThreadPinnedEventThrows.java
Alan Bateman
alanb at openjdk.org
Sun Sep 10 07:05:50 UTC 2023
On Fri, 8 Sep 2023 02:20:25 GMT, ywj <duke at openjdk.org> wrote:
> This test is for testing parking when pinned and VirtualThreadPinnedEvent.commit fails with OOME.However, this test can also pass if OOM is not thrown.Therefore, it is not possible to determine whether VirtualThreadPinnedEvent has thrown an exception.
>
> In reference to the parkOnCarrierThread method in VirtualThread in JDK 22, if OOM (Out of Memory Error) is thrown, then the event will be null.
>
> private void parkOnCarrierThread(boolean timed, long nanos) {
> assert state() == RUNNING;
>
> VirtualThreadPinnedEvent event;
> try {
> event = new VirtualThreadPinnedEvent();
> event.begin();
> } catch (OutOfMemoryError e) {
> event = null;
> }
>
> So, I added a condition to confirm that OOM (Out of Memory Error) has been thrown and that the event is null (assertEquals(0, virtualThreadPinnedEventCount);).
The purpose of this test is to exercise code paths for parking while pinned that could potentially throw OOME. It's essentially that park does not fail. It's hard to create reliable tests for OOME so this test runs with a patched version of VirtualThreadPinnedEvent that allows the test control if OOME thrown by any of the 3 methods where it interacts with JFR (create, begin, commit). So JFR is not used. If I understand your change correctly, you want this extended to test that a JFR event is not recorded. Do you view this as a "test for the test"? I'm just wondering if this additional complexity (and overlap with the JfrEvents test) is needed.
-------------
PR Comment: https://git.openjdk.org/loom/pull/205#issuecomment-1712733984
More information about the loom-dev
mailing list