RFR: JMC-6141: JMC logs warnings when creating recordings [v2]
Alex Macdonald
aptmac at openjdk.java.net
Fri Jun 25 14:15:25 UTC 2021
> This PR addresses JMC-6141 [[0]](https://bugs.openjdk.java.net/browse/JMC-6141), in which JMC logs warnings when creating recordings. This is particularly annoying when running unit tests because the terminal gets flooded with warnings.
>
> There are two problems here.
>
> The first problem is that the `JFR_SETTINGS_PERIOD` constant in EventTypeMetadataV2 is outdated. It is currently hardcoded as `com.oracle.jfr.settings.Period` which looks to have been the name prior to open-sourcing [[1]](https://github.com/alibaba/dragonwell8_jdk/blob/423386885af50cf6f956d1b1ba159a994045a8ae/src/share/classes/jdk/jfr/internal/settings/PeriodSetting.java/#L43), but has since become `jdk.settings.Period` [[2]](https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java#L42)[[3]](https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java#L53). This removes the warnings related to `WARNING: Inferred content type 'jdk.jfr.Period' for option Period`.
>
> The second problem is that there isn't any handling for the value "infinity" when parsing the timespan. The method `parsePersisted()` in LinearKindOfQuantity looks at the persisted string and uses regex to separate the unit from the value. In this case with period however, if the timespan is infinite then the string is just "infinity", so the regex doesn't work and we end up throwing an exception. I took some inspiration from the jfr code [[4]](https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java#L77), and it handles infinite timespans by checking the string, and if it is "infinity" then returns the max long value [[5]](https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java#L304). I've added a unit test to reinforce this behaviour.
>
> Let me know if this approach is okay, and if there are different options I need to consider.
>
> After these two changes my test output is legible, and I haven't noticed and regressions with uitests or my manual testing. When doing a regular `mvn clean verify` for the application we see a reduction of 12800 logged lines.
>
> [0] https://bugs.openjdk.java.net/browse/JMC-6141
> [1] https://github.com/alibaba/dragonwell8_jdk/blob/423386885af50cf6f956d1b1ba159a994045a8ae/src/share/classes/jdk/jfr/internal/settings/PeriodSetting.java/#L43
> [2] https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java#L42
> [3] https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java#L53
> [4] https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java#L116
> [5] https://github.com/openjdk/jdk/blob/master/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java#L304
Alex Macdonald has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
JMC-6141: JMC logs warnings when creating recordings
-------------
Changes:
- all: https://git.openjdk.java.net/jmc/pull/270/files
- new: https://git.openjdk.java.net/jmc/pull/270/files/0577f829..a928e796
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jmc&pr=270&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jmc&pr=270&range=00-01
Stats: 6 lines in 1 file changed: 6 ins; 0 del; 0 mod
Patch: https://git.openjdk.java.net/jmc/pull/270.diff
Fetch: git fetch https://git.openjdk.java.net/jmc pull/270/head:pull/270
PR: https://git.openjdk.java.net/jmc/pull/270
More information about the jmc-dev
mailing list