Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
8309959: JFR: Display N/A for missing data amount
Browse files Browse the repository at this point in the history
Reviewed-by: egahlin
Backport-of: 9872a14192ce3964b934c19ab685342ffd396986
  • Loading branch information
fthevenet authored and egahlin committed Jun 26, 2023
1 parent 7489967 commit f0e80fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java
Expand Up @@ -121,11 +121,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
Expand Up @@ -146,11 +146,13 @@ public static String formatClass(RecordedClass clazz) {
return name;
}

// 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 f0e80fa

@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.