Skip to content
Permalink
Browse files

8210977: jdk/jfr/event/oldobject/TestThreadLocalLeak.java fails to fi…

…nd ThreadLocalObject

Reviewed-by: mgronlun, mseledtsov
  • Loading branch information
Erik Gahlin
Erik Gahlin committed Feb 18, 2020
1 parent 58a0360 commit f3cd52e3c73ad525456a20b5190a3a97e862ec15
Showing with 13 additions and 9 deletions.
  1. +13 −9 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
@@ -57,14 +57,18 @@
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();
}
}
}

0 comments on commit f3cd52e

Please sign in to comment.