Skip to content

Commit 8f216db

Browse files
committed
Remove @Nullable on local variables
>> `@Nullable` and `@NonNull` aren't applied to local variables—at least not their root types. (They should be applied to type arguments and array components.) The reason is that it is possible to infer whether a variable can be null based on the values that are assigned to the variable. Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
1 parent fd2e1d2 commit 8f216db

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/jsontest/app/ExampleJacksonComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ static class Serializer extends ObjectValueSerializer<ExampleCustomObject> {
4545
@Override
4646
protected void serializeObject(ExampleCustomObject value, JsonGenerator jgen, SerializationContext context) {
4747
jgen.writeStringProperty("value", value.value());
48-
@Nullable Date date = value.date();
48+
Date date = value.date();
4949
if (date != null) {
5050
jgen.writeNumberProperty("date", date.getTime());
5151
}
52-
@Nullable UUID uuid = value.uuid();
52+
UUID uuid = value.uuid();
5353
if (uuid != null) {
5454
jgen.writeStringProperty("uuid", uuid.toString());
5555
}

module/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaBaseConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public EntityManagerFactoryBuilder entityManagerFactoryBuilder(JpaVendorAdapter
125125
ObjectProvider<PersistenceUnitManager> persistenceUnitManager,
126126
ObjectProvider<EntityManagerFactoryBuilderCustomizer> customizers,
127127
Map<String, AsyncTaskExecutor> taskExecutors) {
128-
@Nullable AsyncTaskExecutor bootstrapExecutor = determineBootstrapExecutor(taskExecutors);
128+
AsyncTaskExecutor bootstrapExecutor = determineBootstrapExecutor(taskExecutors);
129129
EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(jpaVendorAdapter,
130130
this::buildJpaProperties, persistenceUnitManager.getIfAvailable(), null, bootstrapExecutor);
131131
if (this.properties.getBootstrap() == Bootstrap.ASYNC) {

module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/PropertiesMeterFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC
125125
if (values.isEmpty()) {
126126
return defaultValue;
127127
}
128-
@Nullable T result = doLookup(values, id);
128+
T result = doLookup(values, id);
129129
return (result != null) ? result : values.getOrDefault("all", defaultValue);
130130
}
131131

module/spring-boot-security-saml2/src/main/java/org/springframework/boot/security/saml2/autoconfigure/Saml2RelyingPartyRegistrationConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private RelyingPartyRegistration asRegistration(String id, Registration properti
107107
.forEach(credentials::add)));
108108
builder.singleLogoutServiceLocation(properties.getSinglelogout().getUrl());
109109
builder.singleLogoutServiceResponseLocation(properties.getSinglelogout().getResponseUrl());
110-
@Nullable Saml2MessageBinding binding = properties.getSinglelogout().getBinding();
110+
Saml2MessageBinding binding = properties.getSinglelogout().getBinding();
111111
if (binding != null) {
112112
builder.singleLogoutServiceBinding(binding);
113113
}

smoke-test/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ProducerApplication(ServiceProperties serviceProperties) {
4141

4242
@Override
4343
public void run(ApplicationArguments args) throws Exception {
44-
@Nullable File inputDir = this.serviceProperties.getInputDir();
44+
File inputDir = this.serviceProperties.getInputDir();
4545
Assert.notNull(inputDir, "No inputDir configured");
4646
inputDir.mkdirs();
4747
if (!args.getNonOptionArgs().isEmpty()) {

smoke-test/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ProducerApplication(ServiceProperties serviceProperties) {
4141

4242
@Override
4343
public void run(ApplicationArguments args) throws Exception {
44-
@Nullable File inputDir = this.serviceProperties.getInputDir();
44+
File inputDir = this.serviceProperties.getInputDir();
4545
Assert.notNull(inputDir, "No inputDir configured");
4646
inputDir.mkdirs();
4747
if (!args.getNonOptionArgs().isEmpty()) {

0 commit comments

Comments
 (0)