Title: SimplePerformantInstrumentation hooks declares InstrumentationState non-null but createState returns null by default · Issue #4433 · graphql-java/graphql-java · GitHub
Open Graph Title: SimplePerformantInstrumentation hooks declares InstrumentationState non-null but createState returns null by default · Issue #4433 · graphql-java/graphql-java
X Title: SimplePerformantInstrumentation hooks declares InstrumentationState non-null but createState returns null by default · Issue #4433 · graphql-java/graphql-java
Description: Describe the bug In graphql-java 26, SimplePerformantInstrumentation is annotated with @NullMarked. Its unannotated InstrumentationState callback parameters are therefore exposed to Kotlin as non-null. However, createState() and createSt...
Open Graph Description: Describe the bug In graphql-java 26, SimplePerformantInstrumentation is annotated with @NullMarked. Its unannotated InstrumentationState callback parameters are therefore exposed to Kotlin as non-n...
X Description: Describe the bug In graphql-java 26, SimplePerformantInstrumentation is annotated with @NullMarked. Its unannotated InstrumentationState callback parameters are therefore exposed to Kotlin as non-n...
Opengraph URL: https://github.com/graphql-java/graphql-java/issues/4433
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SimplePerformantInstrumentation hooks declares InstrumentationState non-null but createState returns null by default","articleBody":"**Describe the bug**\nIn graphql-java 26, `SimplePerformantInstrumentation` is annotated with `@NullMarked`. Its unannotated `InstrumentationState` callback parameters are therefore exposed to Kotlin as non-null.\n\nHowever, `createState()` and `createStateAsync()` remain explicitly nullable, and the default `SimplePerformantInstrumentation.createState()` implementation returns `null`.\n\nThis appears to be a nullability-contract mismatch introduced by the [JSpecify instrumentation changes in #4272](https://github.com/graphql-java/graphql-java/pull/4272).\n\nThe callback state parameters should either be annotated `@Nullable`, matching the existing optional-state behavior, or graphql-java should guarantee a non-null empty state. Making the parameters nullable would preserve the existing runtime contract.\n\n**To Reproduce**\nPlease provide a code example or even better a test to reproduce the bug.\n\n```kotlin\n import graphql.ExecutionResult\n import graphql.GraphQL\n import graphql.execution.instrumentation.InstrumentationContext\n import graphql.execution.instrumentation.InstrumentationState\n import graphql.execution.instrumentation.SimplePerformantInstrumentation\n import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters\n import graphql.schema.idl.RuntimeWiring\n import graphql.schema.idl.SchemaGenerator\n import graphql.schema.idl.SchemaParser\n import kotlin.test.Test\n\n class InstrumentationStateNullabilityTest {\n\n private class StatelessInstrumentation : SimplePerformantInstrumentation() {\n override fun beginExecution(\n parameters: InstrumentationExecutionParameters,\n state: InstrumentationState\n ): InstrumentationContext\u003cExecutionResult>? = null\n }\n\n @Test\n fun `stateless Kotlin instrumentation should execute without an NPE`() {\n val typeRegistry = SchemaParser().parse(\n \"\"\"\n type Query {\n hello: String\n }\n \"\"\".trimIndent()\n )\n val schema = SchemaGenerator().makeExecutableSchema(\n typeRegistry,\n RuntimeWiring.MOCKED_WIRING\n )\n val graphQL = GraphQL.newGraphQL(schema)\n .instrumentation(StatelessInstrumentation())\n .build()\n\n graphQL.execute(\"{ hello }\")\n }\n }\n```\n\nThe execution fails when `beginExecution` is invoked:\n\n```\n java.lang.NullPointerException:\n Parameter specified as non-null is null:\n method StatelessInstrumentation.beginExecution, parameter state\n```\n\nA current workaround is to return a non-null marker state:\n\n```kotlin\nprivate object EmptyInstrumentationState : InstrumentationState\n\n override fun createState(\n parameters: InstrumentationCreateStateParameters\n ): InstrumentationState = EmptyInstrumentationState\n```\n","author":{"url":"https://github.com/samuelAndalon","@type":"Person","name":"samuelAndalon"},"datePublished":"2026-08-04T22:19:29Z","url":"https://github.com/graphql-java/graphql-java/issues/4433"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:879834e4-2a04-f1f3-fbd8-87d9110d8222 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9D2:20309E:A4EEC6:D84D08:6AED4344 |
| html-safe-nonce | 116d6a7165f7a381716bf9135541ec3a2b7047a3c5679ca47b841e3d48b01d20 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUQyOjIwMzA5RTpBNEVFQzY6RDg0RDA4OjZBRUQ0MzQ0IiwidmlzaXRvcl9pZCI6IjI2NjA1MjMzODE3MDEyOTY5NjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6e44c2ff7fb52f1155bac9662f78b0172655898da35afcbdd80988e5f713317d |
| hovercard-subject-tag | issue:5065391277 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-java/graphql-java/4433/issue_layout |
| twitter:image | https://opengraph.githubassets.com/edadaa3139cef649411028f1285de8b684abc652091c1a87a898dc9df73fcf39/graphql-java/graphql-java/issues/4433 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/edadaa3139cef649411028f1285de8b684abc652091c1a87a898dc9df73fcf39/graphql-java/graphql-java/issues/4433 |
| og:image:alt | Describe the bug In graphql-java 26, SimplePerformantInstrumentation is annotated with @NullMarked. Its unannotated InstrumentationState callback parameters are therefore exposed to Kotlin as non-n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | samuelAndalon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11 |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width