RFR: 8439: ArithmeticException thrown when plotting event count histogram with maxDuration set to 0 [v2]
Aymane Harmaz
duke at openjdk.org
Thu Sep 25 17:36:51 UTC 2025
On Thu, 25 Sep 2025 15:07:53 GMT, Marcus Hirt <hirt at openjdk.org> wrote:
>> Aymane Harmaz has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Implemented review comment
>
> 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
Thanks for the insight.
I used `clampedLongValueIn` as the only critical case here is equality with 0L, and this way we don’t need to handle conversion exceptions explicitly
-------------
PR Review Comment: https://git.openjdk.org/jmc/pull/675#discussion_r2379858839
More information about the jmc-dev
mailing list