8210977: jdk/jfr/event/oldobject/TestThreadLocalLeak.java fails to find ThreadLocalObject
Reviewed-by: mgronlun, mseledtsov
This commit is contained in:
parent
58a0360039
commit
f3cd52e3c7
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 {
|
public static void main(String[] args) throws Exception {
|
||||||
WhiteBox.setWriteAllObjectSamples(true);
|
WhiteBox.setWriteAllObjectSamples(true);
|
||||||
|
|
||||||
try (Recording r = new Recording()) {
|
while (true) {
|
||||||
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
|
try (Recording r = new Recording()) {
|
||||||
r.start();
|
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
|
||||||
allocateThreadLocal();
|
r.start();
|
||||||
r.stop();
|
allocateThreadLocal();
|
||||||
List<RecordedEvent> events = Events.fromRecording(r);
|
r.stop();
|
||||||
if (OldObjects.countMatchingEvents(events, ThreadLocalObject[].class, null, null, -1, "allocateThreadLocal") == 0) {
|
List<RecordedEvent> events = Events.fromRecording(r);
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user