8208249: TriggerUnloadingByFillingMetaspace generates garbage class names
Summary: Put a ThreadLocal around the object to be thread safe
Reviewed-by: tschatzl, iignatyev
--- a/test/hotspot/jtreg/vmTestbase/vm/share/gc/TriggerUnloadingByFillingMetaspace.java Tue Jul 31 12:24:47 2018 -0700
+++ b/test/hotspot/jtreg/vmTestbase/vm/share/gc/TriggerUnloadingByFillingMetaspace.java Tue Jul 31 10:16:56 2018 -0700
@@ -39,7 +39,13 @@
private static class FillMetaspace {
private volatile boolean gotOOME = false;
private ExecutionController stresser;
- private GeneratedClassProducer generatedClassProducer = new GeneratedClassProducer("metaspace.stressHierarchy.common.HumongousClass");
+ private final ThreadLocal<GeneratedClassProducer> generatedClassProducer =
+ new ThreadLocal<GeneratedClassProducer>() {
+ @Override
+ protected GeneratedClassProducer initialValue() {
+ return new GeneratedClassProducer("metaspace.stressHierarchy.common.HumongousClass");
+ }
+ };
public FillMetaspace(ExecutionController stresser) { this.stresser = stresser; }
@@ -48,7 +54,7 @@
public Object call() throws Exception {
while (stresser.continueExecution() && ! gotOOME) {
try {
- generatedClassProducer.create(-100500); //argument is not used.
+ generatedClassProducer.get().create(-100500); //argument is not used.
} catch (OutOfMemoryError oome) {
if (!isInMetaspace(oome)) {
throw new GotWrongOOMEException("Got OOME in heap while gaining OOME in metaspace. Test result can't be valid.");