Skip to content

Commit d7db1a0

Browse files
committed
Apply Nullability changes
This commit removes the new deprecated `org.springframework.lang.Nullable` annotations and replaces them with JSpecify equivalents. Note, because those new annotations are applied on type usage, this commit not only renames imports, but also moves annotations close to the nullable usage types. Closes gh-1132
1 parent 5acb64e commit d7db1a0

File tree

130 files changed

+566
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+566
-702
lines changed

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
2828
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
2929
import com.jayway.jsonpath.spi.mapper.MappingProvider;
30+
import org.jspecify.annotations.Nullable;
3031
import reactor.core.publisher.Flux;
3132
import reactor.core.publisher.Mono;
3233

@@ -40,7 +41,6 @@
4041
import org.springframework.graphql.client.GraphQlTransport;
4142
import org.springframework.graphql.support.DocumentSource;
4243
import org.springframework.graphql.support.ResourceDocumentSource;
43-
import org.springframework.lang.Nullable;
4444
import org.springframework.util.Assert;
4545
import org.springframework.util.ClassUtils;
4646

@@ -66,8 +66,7 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
6666
private static final Duration DEFAULT_RESPONSE_DURATION = Duration.ofSeconds(5);
6767

6868

69-
@Nullable
70-
private Predicate<ResponseError> errorFilter;
69+
private @Nullable Predicate<ResponseError> errorFilter;
7170

7271
private DocumentSource documentSource;
7372

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultExecutionGraphQlServiceTesterBuilder.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
import java.util.function.Consumer;
2525

2626
import graphql.ExecutionInput;
27+
import org.jspecify.annotations.Nullable;
2728

2829
import org.springframework.core.codec.Decoder;
2930
import org.springframework.core.codec.Encoder;
3031
import org.springframework.graphql.ExecutionGraphQlService;
31-
import org.springframework.lang.Nullable;
3232
import org.springframework.util.Assert;
3333

3434

@@ -46,11 +46,9 @@ final class DefaultExecutionGraphQlServiceTesterBuilder
4646

4747
private final List<BiFunction<ExecutionInput, ExecutionInput.Builder, ExecutionInput>> executionInputConfigurers;
4848

49-
@Nullable
50-
private Encoder<?> encoder;
49+
private @Nullable Encoder<?> encoder;
5150

52-
@Nullable
53-
private Decoder<?> decoder;
51+
private @Nullable Decoder<?> decoder;
5452

5553

5654
DefaultExecutionGraphQlServiceTesterBuilder(ExecutionGraphQlService service) {

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.jayway.jsonpath.DocumentContext;
3232
import com.jayway.jsonpath.JsonPath;
3333
import com.jayway.jsonpath.TypeRef;
34+
import org.jspecify.annotations.Nullable;
3435
import org.skyscreamer.jsonassert.JSONAssert;
3536

3637
import org.springframework.core.ParameterizedTypeReference;
@@ -41,7 +42,6 @@
4142
import org.springframework.graphql.client.GraphQlTransport;
4243
import org.springframework.graphql.support.DefaultGraphQlRequest;
4344
import org.springframework.graphql.support.DocumentSource;
44-
import org.springframework.lang.Nullable;
4545
import org.springframework.test.util.AssertionErrors;
4646
import org.springframework.test.util.JsonPathExpectationsHelper;
4747
import org.springframework.util.Assert;
@@ -61,8 +61,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
6161

6262
private final GraphQlTransport transport;
6363

64-
@Nullable
65-
private final Predicate<ResponseError> errorFilter;
64+
private final @Nullable Predicate<ResponseError> errorFilter;
6665

6766
private final Configuration jsonPathConfig;
6867

@@ -120,8 +119,7 @@ private final class DefaultRequest implements Request<DefaultRequest> {
120119

121120
private final String document;
122121

123-
@Nullable
124-
private String operationName;
122+
private @Nullable String operationName;
125123

126124
List<String> fragments = new ArrayList<>();
127125

@@ -173,7 +171,7 @@ public DefaultRequest extension(String name, @Nullable Object value) {
173171
return this;
174172
}
175173

176-
@SuppressWarnings("ConstantConditions")
174+
@SuppressWarnings({"ConstantConditions", "NullAway"})
177175
@Override
178176
public Response execute() {
179177
return DefaultGraphQlTester.this.transport.execute(request())
@@ -374,8 +372,7 @@ public Traversable satisfy(Consumer<List<ResponseError>> consumer) {
374372
*/
375373
private static final class DefaultPath implements Path {
376374

377-
@Nullable
378-
private final String basePath;
375+
private final @Nullable String basePath;
379376

380377
private final String path;
381378

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/EncoderDecoderMappingProvider.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.jayway.jsonpath.Configuration;
2626
import com.jayway.jsonpath.TypeRef;
2727
import com.jayway.jsonpath.spi.mapper.MappingProvider;
28+
import org.jspecify.annotations.Nullable;
2829

2930
import org.springframework.core.ResolvableType;
3031
import org.springframework.core.codec.Decoder;
@@ -36,7 +37,6 @@
3637
import org.springframework.http.codec.CodecConfigurer;
3738
import org.springframework.http.codec.DecoderHttpMessageReader;
3839
import org.springframework.http.codec.EncoderHttpMessageWriter;
39-
import org.springframework.lang.Nullable;
4040
import org.springframework.util.MimeType;
4141
import org.springframework.util.MimeTypeUtils;
4242

@@ -107,21 +107,18 @@ private static Decoder<?> findJsonDecoder(Stream<Decoder<?>> decoderStream) {
107107
}
108108

109109

110-
@Nullable
111110
@Override
112-
public <T> T map(Object source, Class<T> targetType, Configuration configuration) {
111+
public @Nullable <T> T map(Object source, Class<T> targetType, Configuration configuration) {
113112
return mapToTargetType(source, ResolvableType.forClass(targetType));
114113
}
115114

116-
@Nullable
117115
@Override
118-
public <T> T map(Object source, TypeRef<T> targetType, Configuration configuration) {
116+
public @Nullable <T> T map(Object source, TypeRef<T> targetType, Configuration configuration) {
119117
return mapToTargetType(source, ResolvableType.forType(targetType.getType()));
120118
}
121119

122120
@SuppressWarnings("unchecked")
123-
@Nullable
124-
private <T> T mapToTargetType(Object source, ResolvableType targetType) {
121+
private @Nullable <T> T mapToTargetType(Object source, ResolvableType targetType) {
125122

126123
DataBufferFactory bufferFactory = DefaultDataBufferFactory.sharedInstance;
127124
MimeType mimeType = MimeTypeUtils.APPLICATION_JSON;

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlTester.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.function.Consumer;
2323
import java.util.function.Predicate;
2424

25+
import org.jspecify.annotations.Nullable;
2526
import reactor.core.publisher.Flux;
2627

2728
import org.springframework.core.ParameterizedTypeReference;
@@ -30,7 +31,6 @@
3031
import org.springframework.graphql.client.GraphQlTransport;
3132
import org.springframework.graphql.support.DocumentSource;
3233
import org.springframework.graphql.support.ResourceDocumentSource;
33-
import org.springframework.lang.Nullable;
3434

3535
/**
3636
* Define a workflow to test GraphQL requests that is independent of the

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/WebGraphQlHandlerGraphQlTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.net.URI;
2121
import java.util.Collections;
2222

23+
import org.jspecify.annotations.Nullable;
2324
import reactor.core.publisher.Mono;
2425

2526
import org.springframework.graphql.ExecutionGraphQlRequest;
@@ -28,7 +29,6 @@
2829
import org.springframework.graphql.server.WebGraphQlRequest;
2930
import org.springframework.http.HttpHeaders;
3031
import org.springframework.http.codec.CodecConfigurer;
31-
import org.springframework.lang.Nullable;
3232

3333

3434
/**

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/package-info.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2020 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
1717
/**
1818
* GraphQL client testing support.
1919
*/
20-
@NonNullApi
21-
@NonNullFields
20+
@NullMarked
2221
package org.springframework.graphql.test.tester;
2322

24-
import org.springframework.lang.NonNullApi;
25-
import org.springframework.lang.NonNullFields;
23+
import org.jspecify.annotations.NullMarked;

spring-graphql/src/main/java/org/springframework/graphql/ExecutionGraphQlRequest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
import graphql.ExecutionInput;
2323
import graphql.execution.ExecutionId;
24-
25-
import org.springframework.lang.Nullable;
24+
import org.jspecify.annotations.Nullable;
2625

2726

2827
/**
@@ -70,14 +69,12 @@ public interface ExecutionGraphQlRequest extends GraphQlRequest {
7069
/**
7170
* Return the configured {@link #executionId(ExecutionId) executionId}.
7271
*/
73-
@Nullable
74-
ExecutionId getExecutionId();
72+
@Nullable ExecutionId getExecutionId();
7573

7674
/**
7775
* Return the transport assigned locale value, if any.
7876
*/
79-
@Nullable
80-
Locale getLocale();
77+
@Nullable Locale getLocale();
8178

8279
/**
8380
* Provide a {@code BiFunction} to help initialize the {@link ExecutionInput}

spring-graphql/src/main/java/org/springframework/graphql/GraphQlRequest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import java.util.Map;
2020

21-
import org.springframework.lang.Nullable;
21+
import org.jspecify.annotations.Nullable;
2222

2323

2424
/**
@@ -45,11 +45,10 @@ public interface GraphQlRequest {
4545
* Return the name of the operation in the {@link #getDocument() document}
4646
* to execute, if the document contains multiple operations.
4747
*/
48-
@Nullable
49-
String getOperationName();
48+
@Nullable String getOperationName();
5049

5150
/**
52-
* Return values for variable defined by the operation.
51+
* Return values for variables defined by the operation.
5352
*/
5453
Map<String, Object> getVariables();
5554

spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23-
import org.springframework.lang.Nullable;
23+
import org.jspecify.annotations.Nullable;
2424

2525
/**
2626
* Represents a GraphQL response with the result of executing a request operation.
@@ -51,8 +51,7 @@ public interface GraphQlResponse {
5151
* is not {@link #isValid() valid}.
5252
* @param <T> a map or a list
5353
*/
54-
@Nullable
55-
<T> T getData();
54+
@Nullable <T> T getData();
5655

5756
/**
5857
* Return errors included in the response.

spring-graphql/src/main/java/org/springframework/graphql/ResponseError.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
import graphql.ErrorClassification;
2323
import graphql.language.SourceLocation;
24-
25-
import org.springframework.lang.Nullable;
24+
import org.jspecify.annotations.Nullable;
2625

2726
/**
2827
* Represents a GraphQL response error.
@@ -36,8 +35,7 @@ public interface ResponseError {
3635
* Return the message with a description of the error intended for the
3736
* developer as a guide to understand and correct the error.
3837
*/
39-
@Nullable
40-
String getMessage();
38+
@Nullable String getMessage();
4139

4240
/**
4341
* Return a classification for the error that is specific to GraphQL Java.

spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
import java.util.List;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.graphql.client.ClientGraphQlResponse;
22-
import org.springframework.lang.Nullable;
2324

2425

2526
/**
@@ -49,8 +50,7 @@ public interface ResponseField {
4950
* @param <T> the expected value type to cast to
5051
* @return the value
5152
*/
52-
@Nullable
53-
<T> T getValue();
53+
@Nullable <T> T getValue();
5454

5555
/**
5656
* Return all errors that have a path, and it is at above, or below the field path.

spring-graphql/src/main/java/org/springframework/graphql/client/AbstractGraphQlClientBuilder.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import java.util.List;
2424
import java.util.function.Consumer;
2525

26+
import org.jspecify.annotations.Nullable;
27+
2628
import org.springframework.core.codec.Decoder;
2729
import org.springframework.core.codec.Encoder;
2830
import org.springframework.core.io.ClassPathResource;
@@ -33,7 +35,6 @@
3335
import org.springframework.graphql.support.ResourceDocumentSource;
3436
import org.springframework.http.codec.json.Jackson2JsonDecoder;
3537
import org.springframework.http.codec.json.Jackson2JsonEncoder;
36-
import org.springframework.lang.Nullable;
3738
import org.springframework.util.Assert;
3839
import org.springframework.util.ClassUtils;
3940

@@ -62,14 +63,11 @@ public abstract class AbstractGraphQlClientBuilder<B extends AbstractGraphQlClie
6263

6364
private DocumentSource documentSource;
6465

65-
@Nullable
66-
private Encoder<?> jsonEncoder;
66+
private @Nullable Encoder<?> jsonEncoder;
6767

68-
@Nullable
69-
private Decoder<?> jsonDecoder;
68+
private @Nullable Decoder<?> jsonDecoder;
7069

71-
@Nullable
72-
private Duration blockingTimeout;
70+
private @Nullable Duration blockingTimeout;
7371

7472

7573
/**

spring-graphql/src/main/java/org/springframework/graphql/client/AbstractGraphQlClientSyncBuilder.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.List;
2323
import java.util.function.Consumer;
2424

25+
import org.jspecify.annotations.Nullable;
2526
import reactor.core.scheduler.Scheduler;
2627
import reactor.core.scheduler.Schedulers;
2728

@@ -35,7 +36,6 @@
3536
import org.springframework.graphql.support.ResourceDocumentSource;
3637
import org.springframework.http.converter.HttpMessageConverter;
3738
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
38-
import org.springframework.lang.Nullable;
3939
import org.springframework.util.Assert;
4040
import org.springframework.util.ClassUtils;
4141

@@ -65,13 +65,11 @@ public abstract class AbstractGraphQlClientSyncBuilder<B extends AbstractGraphQl
6565

6666
private DocumentSource documentSource;
6767

68-
@Nullable
69-
private HttpMessageConverter<Object> jsonConverter;
68+
private @Nullable HttpMessageConverter<Object> jsonConverter;
7069

7170
private Scheduler scheduler = Schedulers.boundedElastic();
7271

73-
@Nullable
74-
private Duration blockingTimeout;
72+
private @Nullable Duration blockingTimeout;
7573

7674
/**
7775
* Default constructor for use from subclasses.

0 commit comments

Comments
 (0)