RFR: 8439: ArithmeticException thrown when plotting event count histogram with maxDuration set to 0

Marcus Hirt hirt at openjdk.org
Thu Sep 25 15:10:37 UTC 2025


On Tue, 23 Sep 2025 10:07:04 GMT, Aymane Harmaz <duke at openjdk.org> wrote:

> When plotting event count histogram and all event durations are set to 0, the duration range will be evaluated to 0, leading to an ArithmeticException (divid by 0), which stops JMC from plotting that histogram.
> 
> This can be shown on the attached screenshot, where only the percentile table is shown and the histogram chart is missing
> 
> <img width="1506" height="865" alt="missing-histogram" src="https://github.com/user-attachments/assets/7a02b705-83f3-45e9-9feb-91c5904064e7" />

application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/views/histogram/HDRHistogramView.java line 272:

> 270: 			// Get the maximum duration to set chart bounds
> 271: 			IQuantity maxDuration = itemsWithDuration.getAggregate(JdkAggregators.LONGEST_EVENT);
> 272: 			if (maxDuration == null || maxDuration.doubleValueIn(UnitLookup.MILLISECOND) == 0.0) {

Nice catch. To avoid FP equality and unit conversion surprises, please compare against zero using nanoseconds:
maxDuration.longValueIn(UnitLookup.NANOSECOND) == 0L

-------------

PR Review Comment: https://git.openjdk.org/jmc/pull/675#discussion_r2379491986


More information about the jmc-dev mailing list