Skip to content

Commit 162c35f

Browse files
committed
Optimized populating the JFR | Exceptions view
1 parent 4ad98a7 commit 162c35f

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

visualvm/jfr/src/org/graalvm/visualvm/jfr/views/exceptions/ExceptionsNode.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ public boolean visit(String typeName, JFREvent event) {
251251
primaryNode.addChild(secondaryNode);
252252
}
253253

254-
Duration duration;
255-
try { duration = event.getDuration("eventDuration"); } // NOI18N
256-
catch (JFRPropertyNotAvailableException e) { duration = null; } // .jfr v0
257-
secondaryNode.processData(duration);
254+
Duration eventDuration;
255+
try { eventDuration = getDuration(event); }
256+
catch (JFRPropertyNotAvailableException e) { eventDuration = null; } // .jfr v0
257+
secondaryNode.processData(eventDuration);
258258
} else {
259-
Duration duration;
260-
try { duration = event.getDuration("eventDuration"); } // NOI18N
261-
catch (JFRPropertyNotAvailableException e) { duration = null; } // .jfr v0
262-
primaryNode.processData(duration);
259+
Duration eventDuration;
260+
try { eventDuration = getDuration(event); }
261+
catch (JFRPropertyNotAvailableException e) { eventDuration = null; } // .jfr v0
262+
primaryNode.processData(eventDuration);
263263
}
264264
}
265265

@@ -278,6 +278,26 @@ public boolean equals(Object o) {
278278
}
279279

280280

281+
private Boolean durationMode;
282+
283+
private Duration getDuration(JFREvent event) throws JFRPropertyNotAvailableException {
284+
if (Boolean.TRUE.equals(durationMode)) { // v1+
285+
return event.getDuration("eventDuration"); // NOI18N
286+
} else if (Boolean.FALSE.equals(durationMode)) { // v0
287+
return null; // NOI18N
288+
} else { // not initialized yet
289+
try {
290+
Duration eventDuration = event.getDuration("eventDuration");// NOI18N
291+
durationMode = Boolean.TRUE;
292+
return eventDuration;
293+
} catch (JFRPropertyNotAvailableException e) {
294+
durationMode = Boolean.FALSE;
295+
return null; // NOI18N
296+
}
297+
}
298+
}
299+
300+
281301
private static String getName(ExceptionsViewSupport.Aggregation aggregation, JFREvent event) {
282302
try {
283303
if (ExceptionsViewSupport.Aggregation.CLASS.equals(aggregation)) return decodeClassName(event.getClass("thrownClass").getName()); // NOI18N

0 commit comments

Comments
 (0)