Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
29 changes: 16 additions & 13 deletions test/jdk/jdk/jfr/event/oldobject/TestObjectSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Comment on lines +106 to +112
Copy link

@jbachorik jbachorik Sep 2, 2021

Choose a reason for hiding this comment

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

So, this fix about not rewriting sizeLeakN variables in subsequent retries as each retry might have only a subset of those variables properly set, correct?

Copy link
Author

@mgronlun mgronlun Sep 3, 2021

Choose a reason for hiding this comment

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

Correct - this has lead to occasional timeouts.

sizeLeak3 = objectSize;
}
}
Expand Down