Skip to content

Commit

Permalink
8309959: JFR: Display N/A for missing data amount
Browse files Browse the repository at this point in the history
Reviewed-by: stuefe, sgehwolf
Backport-of: 9872a14192ce3964b934c19ab685342ffd396986
  • Loading branch information
fthevenet authored and jerboaa committed Jun 19, 2023
1 parent 6c81bf5 commit 5a4e374
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java
Expand Up @@ -126,11 +126,13 @@ private static enum TimespanUnit {
}
}

// handle Long.MIN_VALUE as a special case since its absolute value is negative
private static String formatDataAmount(String formatter, long amount) {
int exp = (amount == Long.MIN_VALUE) ? 6 : (int) (Math.log(Math.abs(amount)) / Math.log(1024));
char unitPrefix = "kMGTPE".charAt(exp - 1);
return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix);
if (amount == Long.MIN_VALUE) {
return "N/A";
}
int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024));
char unit = "kMGTPE".charAt(exp - 1);
return String.format(formatter, amount / Math.pow(1024, exp), unit);
}

public static String formatBytesCompact(long bytes) {
Expand Down

1 comment on commit 5a4e374

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.