GH-1192 - Migrate code base to jSpecify for nullness verification.

This commit is contained in:
Oliver Drotbohm
2025-02-17 17:10:47 +01:00
parent a136ff920b
commit 9ea2b24b53
134 changed files with 548 additions and 211 deletions

View File

@@ -16,6 +16,11 @@
<dependencies>
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-core</artifactId>

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.modulith.runtime;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;
@@ -44,6 +45,7 @@ public interface ApplicationRuntime {
*
* @return will never be {@literal null}.
*/
@Nullable
String getId();
/**

View File

@@ -18,8 +18,10 @@ package org.springframework.modulith.runtime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
@@ -37,8 +39,8 @@ class SpringBootApplicationRuntime implements ApplicationRuntime {
private static final Map<String, Boolean> APPLICATION_CLASSES = new ConcurrentHashMap<>();
private final ApplicationContext context;
private Class<?> mainApplicationClass;
private List<String> resolvedAutoConfigurationPackages;
private @Nullable Class<?> mainApplicationClass;
private @Nullable List<String> resolvedAutoConfigurationPackages;
/**
* Creates a new {@link SpringBootApplicationRuntime} for the given {@link ApplicationContext}.
@@ -57,7 +59,7 @@ class SpringBootApplicationRuntime implements ApplicationRuntime {
* @see org.springframework.modulith.observability.ApplicationRuntime#getId()
*/
@Override
public String getId() {
public @Nullable String getId() {
return context.getId();
}
@@ -92,7 +94,7 @@ class SpringBootApplicationRuntime implements ApplicationRuntime {
? context.getType(beanName)
: bean.getClass();
return ClassUtils.getUserClass(beanType);
return ClassUtils.getUserClass(Objects.requireNonNull(beanType));
}
/*

View File

@@ -1,5 +1,5 @@
/**
* Autoconfiguration the {@link org.springframework.modulith.core.ApplicationModules} runtime support.
*/
@org.springframework.lang.NonNullApi
@org.jspecify.annotations.NullMarked
package org.springframework.modulith.runtime.autoconfigure;

View File

@@ -1,5 +1,5 @@
/**
* Support to run {@link org.springframework.modulith.core.ApplicationModules} at application runtime.
*/
@org.springframework.lang.NonNullApi
@org.jspecify.annotations.NullMarked
package org.springframework.modulith.runtime;