FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: mark InstrumentationState callback params as @Nullable by arimu1 · Pull Request #4435 · graphql-java/graphql-java · GitHub

fix: mark InstrumentationState callback params as @Nullable - #4435

Merged
andimarek merged 2 commits into
graphql-java:masterfrom
arimu1:fix/4433-nullable-instrumentation-state
Aug 23, 2026
Merged

fix: mark InstrumentationState callback params as @Nullable#4435
andimarek merged 2 commits into
graphql-java:masterfrom
arimu1:fix/4433-nullable-instrumentation-state

Conversation

arimu1 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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:

Parameter specified as non-null is null: method … beginExecution, parameter state

This change annotates callback state parameters as @Nullable to match the existing optional-state runtime contract (preferred fix from the issue).

Changes

  • Annotate InstrumentationState callback parameters @Nullable on Instrumentation, SimplePerformantInstrumentation, ChainedInstrumentation, NoContextChainedInstrumentation, and built-in implementors that override those hooks
  • ChainedInstrumentation asserts non-null when casting to its own ChainedInstrumentationState (always materialized via createStateAsync)
  • Spock coverage for null default createState and full execution with a stateless SimplePerformantInstrumentation subclass

Test plan

  • ./gradlew test --tests graphql.execution.instrumentation.InstrumentationDefaultMethodsTest --tests graphql.execution.instrumentation.InstrumentationTest --tests graphql.execution.instrumentation.ChainedInstrumentationStateTest --tests graphql.execution.instrumentation.NoContextChainedInstrumentationTest --tests graphql.execution.instrumentation.TracingInstrumentationTest (36 tests, Temurin 21)
  • ./gradlew compileJava (NullAway / ErrorProne clean)

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

github-actions Bot commented Aug 20, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 5940 (+2 🟢) 5884 (+2 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 5940 (+2 🟢) 5883 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 5940 (+2 🟢) 5883 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 5940 (+2 🟢) 5883 (+2 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 23792 (+8 🟢) 23565 (+8 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30072 3121 90.6% ±0.0%
Branches 8788 1518 85.3% ±0.0%
Methods 8033 1206 86.9% ±0.0%

Changed Class Coverage (1 class)

Class Line Branch Method
g.e.i.ChainedInstrumentation ±0.0% ±0.0% +0.3% 🟢

Full HTML report: build artifact jacoco-html-report

Updated: 2026-08-22 23:54:25 UTC

andimarek merged commit 5a77294 into graphql-java:master Aug 23, 2026
10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SimplePerformantInstrumentation hooks declares InstrumentationState non-null but createState returns null by default

2 participants


Back | FazBrowse Home | New Git URL