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

Frederic Thevenet fthevenet at openjdk.org
Tue Jun 13 14:51:00 UTC 2023


On Tue, 13 Jun 2023 13:43:24 GMT, Erik Gahlin <egahlin at openjdk.org> wrote:

>> Frederic Thevenet has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Put brackets around the ? condition
>
> JFR uses Long.MIN_VALUE to indicate that a value is not available or not applicable ("N/A"). I think a correct fix should be to check for that before calling the method, or do it in the method.

Thanks for the clarification, @egahlin 

IMHO, putting the responsibility of checking for Long.MIN_VALUE on the caller is taking the risk to run in the same issue in the future, so having `formatDataAmount` return the string `"N/A"` in such a case seems the better solution. 

If we deem it preferable to let callers handle this verification, then I believe we should still consider keeping this patch in - which is at least *technically correct* and avoid a seemingly unrelated exception being thrown - or at least throw a more helpful IllegalArgumentException to avoid further confusion.

What do you think?

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

PR Comment: https://git.openjdk.org/jdk/pull/14341#issuecomment-1589463067


More information about the hotspot-jfr-dev mailing list