@@ -251,15 +251,15 @@ public boolean visit(String typeName, JFREvent event) {
251
251
primaryNode .addChild (secondaryNode );
252
252
}
253
253
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 );
258
258
} 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 );
263
263
}
264
264
}
265
265
@@ -278,6 +278,26 @@ public boolean equals(Object o) {
278
278
}
279
279
280
280
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
+
281
301
private static String getName (ExceptionsViewSupport .Aggregation aggregation , JFREvent event ) {
282
302
try {
283
303
if (ExceptionsViewSupport .Aggregation .CLASS .equals (aggregation )) return decodeClassName (event .getClass ("thrownClass" ).getName ()); // NOI18N
0 commit comments