RFR: 8093: Rules dependant on GarbageCollectionInfoRule throw NPE if there is no gcInfo [v2]

Christoph Langer clanger at openjdk.org
Mon Jun 19 13:48:20 UTC 2023


On Mon, 19 Jun 2023 13:20:32 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. 
>> ![event-browser](https://github.com/openjdk/jmc/assets/10425301/cac8ceaa-34b6-46b3-8a42-14af375a7c51)
>> 
>> 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:
>> ![before](https://github.com/openjdk/jmc/assets/10425301/e4eb6b7f-4055-491c-a5b3-ded5608644d7)
>> 
>> After:
>> ![after](https://github.com/openjdk/jmc/assets/10425301/3caf81ac-b8a8-4b8b-a87f-4bc11f14c8c2)
>> 
>> [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
>
> Alex Macdonald has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update license headers to 2023

Marked as reviewed by clanger (Committer).

-------------

PR Review: https://git.openjdk.org/jmc/pull/498#pullrequestreview-1486277052


More information about the jmc-dev mailing list