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: mgronlun, stuefe
  • Loading branch information
egahlin committed Jun 14, 2023
1 parent 4c18b9e commit 9872a14
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

3 comments on commit 9872a14

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@fthevenet
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21

@openjdk
Copy link

@openjdk openjdk bot commented on 9872a14 Jun 22, 2023

Choose a reason for hiding this comment

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

@fthevenet the backport was successfully created on the branch fthevenet-backport-9872a141 in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 9872a141 from the openjdk/jdk repository.

The commit being backported was authored by Erik Gahlin on 14 Jun 2023 and was reviewed by Markus Grönlund and Thomas Stuefe.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21:

$ git fetch https://github.com/openjdk-bots/jdk21.git fthevenet-backport-9872a141:fthevenet-backport-9872a141
$ git checkout fthevenet-backport-9872a141
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21.git fthevenet-backport-9872a141

Please sign in to comment.