Skip to content

Commit

Permalink
8210977: jdk/jfr/event/oldobject/TestThreadLocalLeak.java fails to fi…
Browse files Browse the repository at this point in the history
…nd ThreadLocalObject

Reviewed-by: mgronlun, mseledtsov
  • Loading branch information
egahlin committed Feb 18, 2020
1 parent 58a0360 commit f3cd52e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/jdk/jdk/jfr/event/oldobject/TestThreadLocalLeak.java
@@ -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
Expand Down Expand Up @@ -57,14 +57,18 @@ static class ThreadLocalObject {
public static void main(String[] args) throws Exception {
WhiteBox.setWriteAllObjectSamples(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);
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) {
return;
}
System.out.println("Failed to find ThreadLocalObject leak. Retrying.");
threadLocal.get().clear();
}
}
}
Expand Down

0 comments on commit f3cd52e

Please sign in to comment.