Describe the bug
The Kotlin-visible signature of GraphQlTester.Request#variables(Map<String, Object> values) in the spring-graphql-test module declares that map values cannot be null, but the JavaDoc explicitly states that null values are supported. This is an inconsistency in the declared contract.
Evidence
The method is declared in GraphQlTester.java:
T variables(Map<String, Object> values);
Its Javadoc states:
@param values the variables to add, possibly with null values since GraphQL supports null for a value vs not providing it at all.
The package is annotated @NullMarked:
@NullMarked
package org.springframework.graphql.test.tester;
Per the JSpecify user guide, inside @NullMarked the type usage Map<String, Object> means non-null keys and non-null values. To allow nullable values the type parameter must be explicitly marked: Map<String, @Nullable Object>.
Comparison with sibling method
The singular setter Request#variable(String name, @Nullable Object value) at line 78 already uses @Nullable on the value parameter, acknowledging that null is a valid variable value. The map form should be consistent with its sibling and its own Javadoc.
Impact
Kotlin consumers cannot pass a map containing null values through variables(...) without @Suppress("UNCHECKED_CAST") as Map<String, Any>, which misrepresents the runtime type and suppresses legitimate null-safety checks. Alternatives such as .filterValues { it != null } silently convert a null GraphQL variable into an absent one — a real semantic change, since GraphQL distinguishes "foo": null from foo being undefined.
Suggested fix
Change the parameter type to:
T variables(Map<String, @Nullable Object> values);
This aligns the declaration with the documented behavior and with the sibling variable(String, @Nullable Object) method, and lets Kotlin consumers pass Map<String, Any?> directly without casts.
Version
Observed on main. The package-level @NullMarked was introduced as part of the JSpecify migration (#1132), so the inconsistency applies to all releases since that migration landed.
Describe the bug
The Kotlin-visible signature of
GraphQlTester.Request#variables(Map<String, Object> values)in thespring-graphql-testmodule declares that map values cannot benull, but the JavaDoc explicitly states thatnullvalues are supported. This is an inconsistency in the declared contract.Evidence
The method is declared in
GraphQlTester.java:Its Javadoc states:
The package is annotated
@NullMarked:Per the JSpecify user guide, inside
@NullMarkedthe type usageMap<String, Object>means non-null keys and non-null values. To allow nullable values the type parameter must be explicitly marked:Map<String, @Nullable Object>.Comparison with sibling method
The singular setter
Request#variable(String name, @Nullable Object value)at line 78 already uses@Nullableon the value parameter, acknowledging thatnullis a valid variable value. The map form should be consistent with its sibling and its own Javadoc.Impact
Kotlin consumers cannot pass a map containing
nullvalues throughvariables(...)without@Suppress("UNCHECKED_CAST") as Map<String, Any>, which misrepresents the runtime type and suppresses legitimate null-safety checks. Alternatives such as.filterValues { it != null }silently convert a null GraphQL variable into an absent one — a real semantic change, since GraphQL distinguishes"foo": nullfromfoobeing undefined.Suggested fix
Change the parameter type to:
This aligns the declaration with the documented behavior and with the sibling
variable(String, @Nullable Object)method, and lets Kotlin consumers passMap<String, Any?>directly without casts.Version
Observed on
main. The package-level@NullMarkedwas introduced as part of the JSpecify migration (#1132), so the inconsistency applies to all releases since that migration landed.