RFR: 8093: Rules dependant on GarbageCollectionInfoRule throw NPE if there is no gcInfo
Alex Macdonald
aptmac at openjdk.org
Fri Jun 16 20:42:27 UTC 2023
This short PR addresses a bug where the four gc rules that depend on GarbageCollectionInfoRule will throw a NPE when evaluating in the case there is no GC information.
This (probably?) won't happen too often, as it requires the jdk.GarbageCollection event to be enabled but never recorded. I was interacting with a handful of short recordings when I ran into this.

The GarbageCollectionInfoRule has it's jdk.GarbageCollection EventAvailability set to AVAILABLE, which means it's looking for the event to be both enabled and have data before evaluating.
The four rules that depend on it have their EventAvailability set to ENABLED, so these rules will run if the event is enabled but even if there's no data. Because GarbageCollectionInfoRule never runs, the aggregate object in the dependant rules is null ([[example]](https://github.com/openjdk/jmc/blob/master/core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/memory/HeapInspectionRule.java#L102) [0]), so a NPE is thrown when trying to evaluate it.
The fix here is to make these rules require the gc events to be available in order to proceed, similar to how GarbageCollectionInfoRule does.
Before:

After:

[0] https://github.com/openjdk/jmc/blob/master/core/org.openjdk.jmc.flightrecorder.rules.jdk/src/main/java/org/openjdk/jmc/flightrecorder/rules/jdk/memory/HeapInspectionRule.java#L102
-------------
Commit messages:
- 8093: Rules dependant on GarbageCollectionInfoRule throw NPE if there is no gcInfo
Changes: https://git.openjdk.org/jmc/pull/498/files
Webrev: https://webrevs.openjdk.org/?repo=jmc&pr=498&range=00
Issue: https://bugs.openjdk.org/browse/JMC-8093
Stats: 4 lines in 4 files changed: 0 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jmc/pull/498.diff
Fetch: git fetch https://git.openjdk.org/jmc.git pull/498/head:pull/498
PR: https://git.openjdk.org/jmc/pull/498
More information about the jmc-dev
mailing list