RFR: 8373293: Change the exception handling in TestNestHostErrorWithMultiThread.java [v2]

Ioi Lam iklam at openjdk.org
Tue Dec 9 05:01:06 UTC 2025


On Tue, 9 Dec 2025 04:10:30 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> To prevent the failure mode seen in [JDK-8372988](https://bugs.openjdk.org/browse/JDK-8372988) we should prevent thread test threads from being terminated by uncaught exceptions, and allow the main thread to detect and throw all errors. That way we should see what the actual failure is.
>> 
>> Testing:
>>  - tiers 1-4 (sanity)
>> 
>> Thanks
>
> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Reviewer suggestion

Changes requested by iklam (Reviewer).

test/hotspot/jtreg/runtime/Nestmates/membership/TestNestHostErrorWithMultiThread.java line 66:

> 64:       if (threadException != null) {
> 65:         throw new Error("TestThread encountered unexpected exception", threadException);
> 66:       }

Comments in [JDK-8372988](https://bugs.openjdk.org/browse/JDK-8372988) mentione the possibility of OOM. When that happens, the above code may get a secondary OOM while doing the `new Error`, thus obscuring the original `threadException`.

I think it's better to make change `main()` to `throws Throwable` and change the above line to


if (threadException != null) {
    Throwable t = threadException;
    try {
        t = new Error("TestThread encountered unexpected exception", threadException);
    } catch (OutOfMemoryError oom) {
        // t may be an OOM. If we get a secondary OOM then just throw the original exception
   }
    throw t;
}

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

PR Review: https://git.openjdk.org/jdk/pull/28713#pullrequestreview-3555459829
PR Review Comment: https://git.openjdk.org/jdk/pull/28713#discussion_r2601096893


More information about the hotspot-runtime-dev mailing list