8210977: jdk/jfr/event/oldobject/TestThreadLocalLeak.java fails to find ThreadLocalObject

Reviewed-by: mgronlun, mseledtsov
This commit is contained in:
Erik Gahlin 2020-02-18 22:25:08 +01:00
parent 58a0360039
commit f3cd52e3c7

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -57,14 +57,18 @@ public class TestThreadLocalLeak {
public static void main(String[] args) throws Exception {
WhiteBox.setWriteAllObjectSamples(true);
while (true) {
try (Recording r = new Recording()) {
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
r.start();
allocateThreadLocal();
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
if (OldObjects.countMatchingEvents(events, ThreadLocalObject[].class, null, null, -1, "allocateThreadLocal") == 0) {
throw new Exception("Could not find thread local object " + ThreadLocalObject.class);
if (OldObjects.countMatchingEvents(events, ThreadLocalObject[].class, null, null, -1, "allocateThreadLocal") > 0) {
return;
}
System.out.println("Failed to find ThreadLocalObject leak. Retrying.");
threadLocal.get().clear();
}
}
}