Skip to content

Commit

Permalink
Fixes duration unit for days from 'f' to 'd'
Browse files Browse the repository at this point in the history
see:

```
java -XX:+FlightRecorder -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10000,maxage=10000m,delay=5f,filename=flight-native.jfr -Xlog:jfr  Main
java.lang.IllegalArgumentException: Integer parsing error nanotime value: illegal unit

whereas

java -XX:+FlightRecorder -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10000,maxage=10000m,delay=5d,filename=flight-native.jfr -Xlog:jfr  Main
[0.562s][info][jfr] Flight Recorder initialized
[0.562s][info][jfr] Created repository /tmp/2021_08_03_01_16_07_454665
[0.567s][info][jfr] Scheduled recording "1" (1) to start at 2021-08-08T01:16:07.684825
```

Signed-off-by: Michal Karm Babacek <karm@redhat.com>
  • Loading branch information
Karm authored and zakkak committed Aug 19, 2021
1 parent 1d4aa97 commit f6bd1cd
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static Long parseDuration(Map<JfrStartArgument, String> args, JfrStartAr
return Duration.ofMinutes(time).toNanos();
} else if ("h".equals(unit)) {
return Duration.ofHours(time).toNanos();
} else if ("f".equals(unit)) {
} else if ("d".equals(unit)) {
return Duration.ofDays(time).toNanos();
}
throw new IllegalArgumentException("Unit is invalid.");
Expand Down Expand Up @@ -233,6 +233,7 @@ private static Long parseMaxSize(Map<JfrStartArgument, String> args, JfrStartArg
case 'G':
return number * 1024 * 1024 * 1024;
default:
// Unknown unit, number is treated as plain bytes
return number;
}
} catch (IllegalArgumentException e) {
Expand Down

0 comments on commit f6bd1cd

Please sign in to comment.