RFR: JDK-8309550: jdk.jfr.internal.Utils::formatDataAmount method should gracefully handle amounts equal to Long.MIN_VALUE

Thomas Stuefe stuefe at openjdk.org
Wed Jun 7 09:41:54 UTC 2023


On Tue, 6 Jun 2023 19:08:11 GMT, Frederic Thevenet <fthevenet at openjdk.org> wrote:

> Please review this simple fix to JDK-8309550.
> 
> NB: The problem originally reported only concerned `src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java`, but since this code was duplicated in `src/jdk.jfr/share/classes/jdk/jfr/internal/util/ValueFormatter.java` with, as far as I understood from the bug description, with an intent to refactor it a a later time, I opted to change both occurrences of the method.

Small nit, otherwise fine.

src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java line 126:

> 124:     // handle Long.MIN_VALUE as a special case since its absolute value is negative
> 125:     private static String formatDataAmount(String formatter, long amount) {
> 126:         int exp = amount == Long.MIN_VALUE ? 6 : (int) (Math.log(Math.abs(amount)) / Math.log(1024));

Here and below: please put brackets around the ? condition.

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

Marked as reviewed by stuefe (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14341#pullrequestreview-1467158117
PR Review Comment: https://git.openjdk.org/jdk/pull/14341#discussion_r1221274822


More information about the hotspot-jfr-dev mailing list