Skip to content
Permalink
Browse files
8269418: jdk/jfr/event/oldobject/TestObjectSize.java failed with "Run…
…timeException: No events: expected false, was true"

Reviewed-by: jbachorik
  • Loading branch information
Markus Grönlund committed Sep 6, 2021
1 parent fb5b144 commit 1bf5bda2919b3236040bf12c51eba552c6309cf7
Showing 2 changed files with 16 additions and 14 deletions.
@@ -832,7 +832,6 @@ jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-
jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64
jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64
jdk/jfr/api/consumer/streaming/TestLatestEvent.java 8268297 windows-x64
jdk/jfr/event/oldobject/TestObjectSize.java 8269418 macosx-x64

############################################################################

@@ -68,30 +68,33 @@ public static void main(String[] args) throws Exception {

final Random rand = new Random(1L);

long sizeLeak1, sizeLeak2, sizeLeak3;
long sizeLeak1 = -1;
long sizeLeak2 = -1;
long sizeLeak3 = -1;

do {
sizeLeak1 = -1;
sizeLeak2 = -1;
sizeLeak3 = -1;

try (Recording recording = new Recording()) {
leak.clear();
recording.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
recording.start();

for (int i = 0; i < 1000; i++) {
switch (rand.nextInt(3)) {
case 0: leak.add(new Leak1()); break;
case 1: leak.add(new Leak2()); break;
case 2: leak.add(new Leak3()); break;
if (sizeLeak1 == -1) {
leak.add(new Leak1());
continue;
}
if (sizeLeak2 == -1) {
leak.add(new Leak2());
continue;
}
if (sizeLeak3 == -1) {
leak.add(new Leak3());
}
}

recording.stop();

List<RecordedEvent> events = Events.fromRecording(recording);
Events.hasEvents(events);
for (RecordedEvent e : events) {
RecordedObject object = e.getValue("object");
RecordedClass type = object.getValue("type");
@@ -100,13 +103,13 @@ public static void main(String[] args) throws Exception {
if (objectSize <= 0) {
throw new Exception("Object size for " + type.getName() + " is lower or equal to 0");
}
if (type.getName().equals(Leak1.class.getName())) {
if (type.getName().equals(Leak1.class.getName()) && sizeLeak1 == -1) {
sizeLeak1 = objectSize;
}
if (type.getName().equals(Leak2.class.getName())) {
if (type.getName().equals(Leak2.class.getName()) && sizeLeak2 == -1) {
sizeLeak2 = objectSize;
}
if (type.getName().equals(Leak3.class.getName())) {
if (type.getName().equals(Leak3.class.getName()) && sizeLeak3 == -1) {
sizeLeak3 = objectSize;
}
}

1 comment on commit 1bf5bda

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 1bf5bda Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.