RFR: 8093: Rules dependant on GarbageCollectionInfoRule throw NPE if there is no gcInfo
Christoph Langer
clanger at openjdk.org
Sat Jun 17 18:48:11 UTC 2023
On Fri, 16 Jun 2023 20:36:21 GMT, Alex Macdonald <aptmac at openjdk.org> wrote:
> 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
Looks good. Please update copyright years before integrating. 😄
-------------
Marked as reviewed by clanger (Committer).
PR Review: https://git.openjdk.org/jmc/pull/498#pullrequestreview-1484872952
More information about the jmc-dev
mailing list