Integrated: 8093: Rules dependant on GarbageCollectionInfoRule throw NPE if there is no gcInfo

Alex Macdonald aptmac at openjdk.org
Mon Jun 19 14:02:19 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. 
> ![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

This pull request has now been integrated.

Changeset: cedf50f6
Author:    Alex Macdonald <aptmac at openjdk.org>
URL:       https://git.openjdk.org/jmc/commit/cedf50f6d00209f2d40d594be5996dc5f8a8a7bd
Stats:     8 lines in 4 files changed: 0 ins; 0 del; 8 mod

8093: Rules dependant on GarbageCollectionInfoRule throw NPE if there is no gcInfo

Reviewed-by: hirt, clanger

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

PR: https://git.openjdk.org/jmc/pull/498


More information about the jmc-dev mailing list