Skip to content

Commit 696d76e

Browse files
Copilotdondonz
andcommitted
Add JSpecify annotations to 10 execution classes
Co-authored-by: dondonz <13839920+dondonz@users.noreply.github.com>
1 parent ea52886 commit 696d76e

11 files changed

Lines changed: 43 additions & 22 deletions

src/main/java/graphql/execution/ExecutionStrategyParameters.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import graphql.Internal;
44
import graphql.PublicApi;
55
import graphql.execution.incremental.AlternativeCallContext;
6+
import org.jspecify.annotations.NullMarked;
67
import org.jspecify.annotations.Nullable;
8+
import org.jspecify.annotations.NullUnmarked;
79

810
import java.util.function.Consumer;
911

@@ -13,6 +15,7 @@
1315
* The parameters that are passed to execution strategies
1416
*/
1517
@PublicApi
18+
@NullMarked
1619
public class ExecutionStrategyParameters {
1720
private final ExecutionStepInfo executionStepInfo;
1821
private final Object source;
@@ -212,6 +215,7 @@ public static Builder newParameters(ExecutionStrategyParameters oldParameters) {
212215
return new Builder(oldParameters);
213216
}
214217

218+
@NullUnmarked
215219
public static class Builder {
216220
ExecutionStepInfo executionStepInfo;
217221
Object source;

src/main/java/graphql/execution/FetchedValue.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import graphql.GraphQLError;
55
import graphql.PublicApi;
66
import graphql.execution.instrumentation.parameters.InstrumentationFieldCompleteParameters;
7+
import org.jspecify.annotations.NullMarked;
78

89
import java.util.List;
910

@@ -12,6 +13,7 @@
1213
* and therefore part of the public despite never used in a method signature.
1314
*/
1415
@PublicApi
16+
@NullMarked
1517
public class FetchedValue {
1618
private final Object fetchedValue;
1719
private final Object localContext;

src/main/java/graphql/execution/FieldValueInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.common.collect.ImmutableList;
44
import graphql.PublicApi;
5+
import org.jspecify.annotations.NullMarked;
56

67
import java.util.List;
78
import java.util.concurrent.CompletableFuture;
@@ -19,6 +20,7 @@
1920
* values might need a call to a database or other systems will tend to be {@link CompletableFuture} promises.
2021
*/
2122
@PublicApi
23+
@NullMarked
2224
public class FieldValueInfo {
2325

2426
public enum CompleteValueType {

src/main/java/graphql/execution/InputMapDefinesTooManyFieldsException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import graphql.language.SourceLocation;
88
import graphql.schema.GraphQLType;
99
import graphql.schema.GraphQLTypeUtil;
10+
import org.jspecify.annotations.NullMarked;
11+
import org.jspecify.annotations.Nullable;
1012

1113
import java.util.List;
1214

@@ -16,14 +18,15 @@
1618
* - This unordered map should not contain any entries with names not defined by a field of this input object type, otherwise an error should be thrown.
1719
*/
1820
@PublicApi
21+
@NullMarked
1922
public class InputMapDefinesTooManyFieldsException extends GraphQLException implements GraphQLError {
2023

2124
public InputMapDefinesTooManyFieldsException(GraphQLType graphQLType, String fieldName) {
2225
super(String.format("The variables input contains a field name '%s' that is not defined for input object type '%s' ", fieldName, GraphQLTypeUtil.simplePrint(graphQLType)));
2326
}
2427

2528
@Override
26-
public List<SourceLocation> getLocations() {
29+
public @Nullable List<SourceLocation> getLocations() {
2730
return null;
2831
}
2932

src/main/java/graphql/execution/MergedSelectionSet.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import com.google.common.collect.ImmutableList;
44
import com.google.common.collect.ImmutableMap;
55
import graphql.PublicApi;
6+
import org.jspecify.annotations.NullMarked;
7+
import org.jspecify.annotations.Nullable;
8+
import org.jspecify.annotations.NullUnmarked;
69

710
import java.util.List;
811
import java.util.Map;
912
import java.util.Set;
1013

1114

1215
@PublicApi
16+
@NullMarked
1317
public class MergedSelectionSet {
1418

1519
private final Map<String, MergedField> subFields;
@@ -36,7 +40,7 @@ public Set<String> keySet() {
3640
return subFields.keySet();
3741
}
3842

39-
public MergedField getSubField(String key) {
43+
public @Nullable MergedField getSubField(String key) {
4044
return subFields.get(key);
4145
}
4246

@@ -52,6 +56,7 @@ public static Builder newMergedSelectionSet() {
5256
return new Builder();
5357
}
5458

59+
@NullUnmarked
5560
public static class Builder {
5661

5762
private Map<String, MergedField> subFields;

src/main/java/graphql/execution/MissingRootTypeException.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@
88
import graphql.GraphQLException;
99
import graphql.PublicApi;
1010
import graphql.language.SourceLocation;
11+
import org.jspecify.annotations.NullMarked;
12+
import org.jspecify.annotations.Nullable;
1113

1214
/**
1315
* This is thrown if a query is attempting to perform an operation not defined in the GraphQL schema
1416
*/
1517
@PublicApi
18+
@NullMarked
1619
public class MissingRootTypeException extends GraphQLException implements GraphQLError {
17-
private List<SourceLocation> sourceLocations;
20+
private @Nullable List<SourceLocation> sourceLocations;
1821

19-
public MissingRootTypeException(String message, SourceLocation sourceLocation) {
22+
public MissingRootTypeException(String message, @Nullable SourceLocation sourceLocation) {
2023
super(message);
2124
this.sourceLocations = sourceLocation == null ? null : Collections.singletonList(sourceLocation);
2225
}
2326

2427
@Override
25-
public List<SourceLocation> getLocations() {
28+
public @Nullable List<SourceLocation> getLocations() {
2629
return sourceLocations;
2730
}
2831

src/main/java/graphql/execution/NonNullableValueCoercedAsNullException.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import graphql.schema.GraphQLInputObjectField;
1111
import graphql.schema.GraphQLType;
1212
import graphql.schema.GraphQLTypeUtil;
13+
import org.jspecify.annotations.NullMarked;
14+
import org.jspecify.annotations.Nullable;
1315

1416
import java.util.Collections;
1517
import java.util.List;
@@ -20,9 +22,10 @@
2022
* This is thrown if a non nullable value is coerced to a null value
2123
*/
2224
@PublicApi
25+
@NullMarked
2326
public class NonNullableValueCoercedAsNullException extends GraphQLException implements GraphQLError {
24-
private List<SourceLocation> sourceLocations;
25-
private List<Object> path;
27+
private @Nullable List<SourceLocation> sourceLocations;
28+
private @Nullable List<Object> path;
2629

2730
public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, GraphQLType graphQLType) {
2831
super(format("Variable '%s' has coerced Null value for NonNull type '%s'",
@@ -74,12 +77,12 @@ public NonNullableValueCoercedAsNullException(GraphQLArgument graphQLArgument) {
7477
}
7578

7679
@Override
77-
public List<SourceLocation> getLocations() {
80+
public @Nullable List<SourceLocation> getLocations() {
7881
return sourceLocations;
7982
}
8083

8184
@Override
82-
public List<Object> getPath() {
85+
public @Nullable List<Object> getPath() {
8386
return path;
8487
}
8588

src/main/java/graphql/execution/NormalizedVariables.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
import graphql.collect.ImmutableKit;
55
import graphql.collect.ImmutableMapWithNullValues;
66
import graphql.normalized.NormalizedInputValue;
7+
import org.jspecify.annotations.NullMarked;
8+
import org.jspecify.annotations.Nullable;
79

810
import java.util.Map;
911

1012
/**
1113
* Holds coerced variables, that is their values are now in a normalized {@link graphql.normalized.NormalizedInputValue} form.
1214
*/
1315
@PublicApi
16+
@NullMarked
1417
public class NormalizedVariables {
1518
private final ImmutableMapWithNullValues<String, NormalizedInputValue> normalisedVariables;
1619

@@ -26,7 +29,7 @@ public boolean containsKey(String key) {
2629
return normalisedVariables.containsKey(key);
2730
}
2831

29-
public Object get(String key) {
32+
public @Nullable Object get(String key) {
3033
return normalisedVariables.get(key);
3134
}
3235

src/main/java/graphql/execution/OneOfNullValueException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55
import graphql.GraphQLException;
66
import graphql.PublicApi;
77
import graphql.language.SourceLocation;
8+
import org.jspecify.annotations.NullMarked;
9+
import org.jspecify.annotations.Nullable;
810

911
import java.util.List;
1012

1113
/**
1214
* The input map to One Of Input Types MUST only have 1 entry with a non null value
1315
*/
1416
@PublicApi
17+
@NullMarked
1518
public class OneOfNullValueException extends GraphQLException implements GraphQLError {
1619

1720
public OneOfNullValueException(String message) {
1821
super(message);
1922
}
2023

2124
@Override
22-
public List<SourceLocation> getLocations() {
25+
public @Nullable List<SourceLocation> getLocations() {
2326
return null;
2427
}
2528

src/main/java/graphql/execution/OneOfTooManyKeysException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55
import graphql.GraphQLException;
66
import graphql.PublicApi;
77
import graphql.language.SourceLocation;
8+
import org.jspecify.annotations.NullMarked;
9+
import org.jspecify.annotations.Nullable;
810

911
import java.util.List;
1012

1113
/**
1214
* The input map to One Of Input Types MUST only have 1 entry
1315
*/
1416
@PublicApi
17+
@NullMarked
1518
public class OneOfTooManyKeysException extends GraphQLException implements GraphQLError {
1619

1720
public OneOfTooManyKeysException(String message) {
1821
super(message);
1922
}
2023

2124
@Override
22-
public List<SourceLocation> getLocations() {
25+
public @Nullable List<SourceLocation> getLocations() {
2326
return null;
2427
}
2528

0 commit comments

Comments
 (0)