Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk21 Public archive

Commit f0e80fa

Browse files
fthevenetegahlin
authored andcommitted
8309959: JFR: Display N/A for missing data amount
Reviewed-by: egahlin Backport-of: 9872a14192ce3964b934c19ab685342ffd396986
1 parent 7489967 commit f0e80fa

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ private static enum TimespanUnit {
121121
}
122122
}
123123

124-
// handle Long.MIN_VALUE as a special case since its absolute value is negative
125124
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));
127-
char unitPrefix = "kMGTPE".charAt(exp - 1);
128-
return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix);
125+
if (amount == Long.MIN_VALUE) {
126+
return "N/A";
127+
}
128+
int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024));
129+
char unit = "kMGTPE".charAt(exp - 1);
130+
return String.format(formatter, amount / Math.pow(1024, exp), unit);
129131
}
130132

131133
public static String formatBytesCompact(long bytes) {

src/jdk.jfr/share/classes/jdk/jfr/internal/util/ValueFormatter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ public static String formatClass(RecordedClass clazz) {
146146
return name;
147147
}
148148

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

156158
public static String formatBytesCompact(long bytes) {

0 commit comments

Comments
 (0)