RFR: modify VirtualThreadPinnedEventThrows.java

ywj duke at openjdk.org
Fri Sep 8 02:26:18 UTC 2023


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);).

-------------

Commit messages:
 - modify

Changes: https://git.openjdk.org/loom/pull/205/files
 Webrev: https://webrevs.openjdk.org/?repo=loom&pr=205&range=00
  Stats: 71 lines in 1 file changed: 52 ins; 1 del; 18 mod
  Patch: https://git.openjdk.org/loom/pull/205.diff
  Fetch: git fetch https://git.openjdk.org/loom.git pull/205/head:pull/205

PR: https://git.openjdk.org/loom/pull/205


More information about the loom-dev mailing list