Add JSpecify annotations to execution instrumentation classes (10 more)#4272
Open
Add JSpecify annotations to execution instrumentation classes (10 more)#4272
Conversation
Annotates the following classes with @NullMarked and appropriate @nullable annotations: - DeferredExecution (label is @nullable per GraphQL spec) - ChainedInstrumentation (removes @nonnull, propagates @nullable from Instrumentation interface) - DocumentAndVariables (@NullUnmarked on Builder) - NoContextChainedInstrumentation (runAll returns @nullable T) - ResponseMapFactory (values are @nullable per Javadoc contract) - SimpleInstrumentation - SimpleInstrumentationContext (@nullable fields, params, onCompleted) - SimplePerformantInstrumentation (removes @nonnull on instrument* overrides) - FieldAndArguments (getParentFieldAndArguments @nullable, getArgumentValue @nullable T) - FieldValidationEnvironment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Test Results 335 files ±0 335 suites ±0 5m 2s ⏱️ -7s Results for commit 15696d4. ± Comparison against base commit 1e867c2. This pull request removes 196 and adds 172 tests. Note that renamed tests count towards both.This pull request skips 1 test.♻️ This comment has been updated with latest results. |
…arameter chainedCtx can return null in the single-instrumentation case since it passes the mapper result through directly, and the underlying Instrumentation begin* methods are @nullable (null is the opt-out signal). The BiFunction return type also needs @nullable so that mapper.apply() is correctly typed as nullable, allowing the nullability to flow from the underlying instrumentation through the lambda to chainedCtx's return. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chainedCtx can return null in the single-instrumentation case since it passes the mapper result through directly, and the underlying Instrumentation begin* methods are @nullable (null is the opt-out signal). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dondonz
commented
Feb 28, 2026
| } | ||
|
|
||
| private <T> InstrumentationContext<T> chainedCtx(InstrumentationState state, BiFunction<Instrumentation, InstrumentationState, InstrumentationContext<T>> mapper) { | ||
| private <T> @Nullable InstrumentationContext<T> chainedCtx(InstrumentationState state, BiFunction<Instrumentation, InstrumentationState, InstrumentationContext<T>> mapper) { |
Member
Author
There was a problem hiding this comment.
This project is a good exercise in catching a bunch of extra nullable annotations
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Annotates execution instrumentation public API classes with
@NullMarkedand appropriate@Nullableannotations, removing them from the JSpecify archunit exemption list.Classes annotated:
DeferredExecution—labelis@Nullableper the GraphQL spec (@deferlabel is optional)ResponseMapFactory— map values are@Nullable Objectsince GraphQL fields can resolve to nullChainedInstrumentation— removes redundant@NonNulloninstrument*overrides (covered by@NullMarked); propagates@Nullablefrom theInstrumentationinterface onto allbegin*return types andonCompletedparametersDocumentAndVariables—@NullUnmarkedonBuilder(uninitialized fields)NoContextChainedInstrumentation—runAll()return type annotated@Nullable T(always returns null)SimpleInstrumentation—@NullMarkedonly; all methods delegate to the interface defaultsSimpleInstrumentationContext—codeToRunOnCompleteandcodeToRunOnDispatchfields are@Nullable(set to null by the no-arg constructor);nonNullCtxparameter andonCompletedparams annotated@NullableSimplePerformantInstrumentation— removes redundant@NonNulloninstrument*overridesFieldAndArguments—getParentFieldAndArguments()is@Nullable(root field has no parent);getArgumentValue()returns@Nullable T(argument values can be absent/null)FieldValidationEnvironment—@NullMarkedonly; all return types are non-nullAlso fixes a pre-existing gap in
Instrumentation:beginDeferredFieldwas the onlybegin*method missing@Nullableon its return type, despite the Javadoc stating it returns "a nullableInstrumentationContext". This would have caused a nullability conflict onceInstrumentationitself becomes@NullMarked.Test plan
JSpecifyAnnotationsCheckpasses — the 10 exemptions for these classes are removed