From b6180e668ecf8ff859910e0fa986f87d1c731a38 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Tue, 18 Sep 2018 11:55:33 -0400 Subject: [PATCH] 8210237: [TESTBUG]gc/stress/TestStressIHOPMultiThread.java fails with 'Unexpected exit from test [exit code: 1]' in CDS mode Fix TestStressIHOPMultiThread to handle possible OutOfMemoryError. Reviewed-by: ccheung, gziemski --- .../jtreg/gc/stress/TestStressIHOPMultiThread.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java b/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java index e0514b124f1..19b3e4343e5 100644 --- a/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java +++ b/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -181,7 +181,13 @@ public class TestStressIHOPMultiThread { public void run() { System.out.println("Start the thread " + threadId); while (TestStressIHOPMultiThread.this.isRunning()) { - allocate(amountOfGarbage); + try { + allocate(amountOfGarbage); + } catch (OutOfMemoryError e) { + free(); + System.out.println("OutOfMemoryError occurred in thread " + threadId); + break; + } free(); } }