createState()/createStateAsync() may return null, and the default
SimplePerformantInstrumentation.createState() does. After @NullMarked
on instrumentation classes (graphql-java#4272), unannotated state parameters were
treated as non-null in Kotlin, causing NPEs for stateless subclasses.
Annotate callback state parameters as @nullable to match the optional-
state runtime contract. ChainedInstrumentation asserts non-null when
casting its own materialized ChainedInstrumentationState.
Fixes graphql-java#4433
Summary
Fixes #4433
After the JSpecify instrumentation annotations in #4272, SimplePerformantInstrumentation (and related @NullMarked instrumentation types) exposed unannotated InstrumentationState callback parameters as non-null to Kotlin. At runtime, createState() / createStateAsync() remain nullable and SimplePerformantInstrumentation.createState() returns null by default, so Kotlin subclasses that override hooks without providing a marker state fail with:
This change annotates callback state parameters as @Nullable to match the existing optional-state runtime contract (preferred fix from the issue).
Changes
Test plan