RFR: 8373293: Change the exception handling in TestNestHostErrorWithMultiThread.java [v2]
David Holmes
dholmes at openjdk.org
Tue Dec 9 05:06:56 UTC 2025
On Tue, 9 Dec 2025 04:58:31 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> David Holmes has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Reviewer suggestion
>
> 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;
> }
Thanks for looking at this @iklam . Good point. Though termination of the thread should free some memory there is certainly no guarantee, so lets try to make this even more exception-proof. Rethrowing another thread's exception can give a confusing stacktrace however.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28713#discussion_r2601107870
More information about the hotspot-runtime-dev
mailing list