Switch to JSpecify annotations

This commit updates the whole Spring Framework codebase to use JSpecify
annotations instead of Spring null-safety annotations with JSR 305
semantics.

JSpecify provides signficant enhancements such as properly defined
specifications, a canonical dependency with no split-package issue,
better tooling, better Kotlin integration and the capability to specify
generic type, array and varargs element null-safety. Generic type
null-safety is not defined by this commit yet and will be specified
later.

A key difference is that Spring null-safety annotations, following
JSR 305 semantics, apply to fields, parameters and return values,
while JSpecify annotations apply to type usages. That's why this
commit moves nullability annotations closer to the type for fields
and return values.

See gh-28797
This commit is contained in:
Sébastien Deleuze
2024-12-03 15:22:37 +01:00
parent fcb8aed03f
commit bc5d771a06
3459 changed files with 14118 additions and 22059 deletions

View File

@@ -19,6 +19,7 @@ package org.springframework.aop.aspectj;
import java.lang.reflect.Method;
import org.aspectj.lang.ProceedingJoinPoint;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -28,7 +29,6 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
/**
* @author Adrian Colyer

View File

@@ -19,6 +19,7 @@ package org.springframework.aop.aspectj;
import java.lang.reflect.Method;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -27,7 +28,6 @@ import org.springframework.aop.framework.Advised;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -29,6 +29,7 @@ import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -66,7 +67,6 @@ import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.DecoratingProxy;
import org.springframework.core.NestedRuntimeException;
import org.springframework.core.annotation.Order;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -30,6 +30,7 @@ import java.util.Map;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -70,7 +71,6 @@ import org.springframework.beans.testfixture.beans.SerializablePerson;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.testfixture.TimeStamped;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;

View File

@@ -20,6 +20,8 @@ import java.io.Serializable;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
@@ -35,8 +37,6 @@ import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@@ -18,6 +18,7 @@ package org.springframework.aop.framework;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
@@ -25,7 +26,6 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.beans.testfixture.beans.IOther;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -25,6 +25,7 @@ import java.util.List;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -58,7 +59,6 @@ import org.springframework.context.testfixture.beans.TestApplicationListener;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.testfixture.TimeStamped;
import org.springframework.core.testfixture.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;

View File

@@ -21,6 +21,7 @@ import java.lang.reflect.Proxy;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.TargetSource;
@@ -45,7 +46,6 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.context.support.StaticMessageSource;
import org.springframework.lang.Nullable;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
@@ -414,8 +414,7 @@ class AutoProxyCreatorTests {
}
@Override
@Nullable
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String name, @Nullable TargetSource customTargetSource) {
protected Object @Nullable [] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String name, @Nullable TargetSource customTargetSource) {
if (StaticMessageSource.class.equals(beanClass)) {
return DO_NOT_PROXY;
}

View File

@@ -18,12 +18,12 @@ package org.springframework.aop.framework.autoproxy;
import java.lang.reflect.Method;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.beans.testfixture.beans.Pet;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import reactor.core.publisher.Flux;
@@ -43,7 +44,6 @@ import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@@ -531,8 +531,7 @@ class CacheReproTests {
}
@Override
@Nullable
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
protected @Nullable Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
String cacheName = (String) context.getArgs()[0];
if (cacheName != null) {
return Collections.singleton(cacheName);

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicLong;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -37,7 +38,6 @@ import org.springframework.cache.interceptor.LoggingCacheErrorHandler;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.catchThrowable;

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
@@ -36,7 +37,6 @@ import org.springframework.context.support.StaticApplicationContext;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.lang.Nullable;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicLong;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -37,7 +38,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.testfixture.cache.CacheTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
@@ -260,8 +260,7 @@ class CacheResolverCustomizationTests {
}
@Override
@Nullable
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
protected @Nullable Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
String cacheName = (String) context.getArgs()[1];
return Collections.singleton(cacheName);
}
@@ -275,8 +274,7 @@ class CacheResolverCustomizationTests {
}
@Override
@Nullable
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
protected @Nullable Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
return null;
}
}

View File

@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.MemberCategory;
@@ -38,7 +39,6 @@ import org.springframework.context.annotation6.Jsr330NamedForScanning;
import org.springframework.context.testfixture.context.annotation.CglibConfiguration;
import org.springframework.context.testfixture.context.annotation.LambdaBeanConfiguration;
import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
import static java.lang.String.format;

View File

@@ -25,6 +25,7 @@ import java.util.function.Predicate;
import javax.lang.model.element.Modifier;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -61,7 +62,6 @@ import org.springframework.core.type.AnnotationMetadata;
import org.springframework.javapoet.CodeBlock;
import org.springframework.javapoet.MethodSpec;
import org.springframework.javapoet.ParameterizedTypeName;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import static org.assertj.core.api.Assertions.assertThat;
@@ -223,9 +223,8 @@ class ConfigurationClassPostProcessorAotContributionTests {
this.metadata = importMetadata;
}
@Nullable
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
public @Nullable Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (beanName.equals("testProcessing")) {
return this.metadata;
}
@@ -441,8 +440,7 @@ class ConfigurationClassPostProcessorAotContributionTests {
}
@Nullable
private BeanFactoryInitializationAotContribution getContribution(Class<?>... types) {
private @Nullable BeanFactoryInitializationAotContribution getContribution(Class<?>... types) {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
for (Class<?> type : types) {
beanFactory.registerBeanDefinition(type.getName(), new RootBeanDefinition(type));

View File

@@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
@@ -46,7 +47,6 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.Nullable;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -403,8 +403,7 @@ public class ImportSelectorTests {
}
@Override
@Nullable
public Predicate<String> getExclusionFilter() {
public @Nullable Predicate<String> getExclusionFilter() {
return className -> className.endsWith("ImportedSelector1");
}
}
@@ -440,18 +439,16 @@ public class ImportSelectorTests {
public static class GroupedDeferredImportSelector1 extends DeferredImportSelector1 {
@Nullable
@Override
public Class<? extends Group> getImportGroup() {
public @Nullable Class<? extends Group> getImportGroup() {
return TestImportGroup.class;
}
}
public static class GroupedDeferredImportSelector2 extends DeferredImportSelector2 {
@Nullable
@Override
public Class<? extends Group> getImportGroup() {
public @Nullable Class<? extends Group> getImportGroup() {
return TestImportGroup.class;
}
}
@@ -471,9 +468,8 @@ public class ImportSelectorTests {
return new String[] { DeferredImportSelector1.class.getName(), ChildConfiguration1.class.getName() };
}
@Nullable
@Override
public Class<? extends DeferredImportSelector.Group> getImportGroup() {
public @Nullable Class<? extends DeferredImportSelector.Group> getImportGroup() {
return TestImportGroup.class;
}
@@ -492,9 +488,8 @@ public class ImportSelectorTests {
return new String[] { DeferredImportSelector2.class.getName(), ChildConfiguration2.class.getName() };
}
@Nullable
@Override
public Class<? extends DeferredImportSelector.Group> getImportGroup() {
public @Nullable Class<? extends DeferredImportSelector.Group> getImportGroup() {
return TestImportGroup.class;
}
@@ -515,9 +510,8 @@ public class ImportSelectorTests {
return new String[] { DeferredImportedSelector3.class.getName() };
}
@Nullable
@Override
public Class<? extends DeferredImportSelector.Group> getImportGroup() {
public @Nullable Class<? extends DeferredImportSelector.Group> getImportGroup() {
return TestImportGroup.class;
}
@@ -537,9 +531,8 @@ public class ImportSelectorTests {
return new String[] { DeferredImportSelector2.class.getName() };
}
@Nullable
@Override
public Class<? extends DeferredImportSelector.Group> getImportGroup() {
public @Nullable Class<? extends DeferredImportSelector.Group> getImportGroup() {
return TestImportGroup.class;
}

View File

@@ -20,6 +20,7 @@ import java.util.List;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.assertj.core.api.ObjectArrayAssert;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
@@ -35,7 +36,6 @@ import org.springframework.context.testfixture.context.aot.scan.reflective.Refle
import org.springframework.context.testfixture.context.aot.scan.reflective2.Reflective2OnType;
import org.springframework.context.testfixture.context.aot.scan.reflective2.reflective21.Reflective21OnType;
import org.springframework.context.testfixture.context.aot.scan.reflective2.reflective22.Reflective22OnType;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -22,6 +22,7 @@ import java.util.Enumeration;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -38,7 +39,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@@ -18,7 +18,7 @@ package org.springframework.context.event.test;
import java.util.UUID;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* @author Stephane Nicoll

View File

@@ -16,9 +16,10 @@
package org.springframework.context.event.test;
import org.jspecify.annotations.Nullable;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;
import org.springframework.lang.Nullable;
/**
* A simple POJO that implements {@link ResolvableTypeProvider}.

View File

@@ -18,8 +18,9 @@ package org.springframework.context.event.test;
import java.util.UUID;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationEvent;
import org.springframework.lang.Nullable;
/**
* A basic test event that can be uniquely identified easily.

View File

@@ -21,6 +21,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.context.ConfigurableApplicationContext;
@@ -31,7 +32,6 @@ import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.ResourceTestBean;
import static org.assertj.core.api.Assertions.assertThat;
@@ -82,8 +82,7 @@ class ConversionServiceFactoryBeanTests {
return Collections.singleton(new ConvertiblePair(String.class, Baz.class));
}
@Override
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
return new Baz();
}
});

View File

@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues;
@@ -34,7 +35,6 @@ import org.springframework.core.ResolvableType;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -25,7 +25,7 @@ import javax.management.MBeanInfo;
import javax.management.MBeanNotificationInfo;
import javax.management.MBeanOperationInfo;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* @author Rob Harrop

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.awaitility.Awaitility;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.Advisor;
@@ -49,7 +50,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
@@ -630,9 +630,8 @@ class EnableAsyncTests {
public static class ExecutorPostProcessor implements BeanPostProcessor {
@Nullable
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
public @Nullable Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof ThreadPoolTaskExecutor) {
((ThreadPoolTaskExecutor) bean).setThreadNamePrefix("Post-");
}

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.awaitility.Awaitility;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -36,7 +37,6 @@ import org.junit.jupiter.api.TestInfo;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@@ -20,9 +20,9 @@ import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.TriggerContext;
import org.springframework.util.NumberUtils;
@@ -227,8 +227,7 @@ class PeriodicTriggerTests {
return new TestTriggerContext(toInstant(scheduled), toInstant(actual), toInstant(completion));
}
@Nullable
private static Instant toInstant(@Nullable Object o) {
private static @Nullable Instant toInstant(@Nullable Object o) {
if (o == null) {
return null;
}
@@ -249,14 +248,11 @@ class PeriodicTriggerTests {
private static class TestTriggerContext implements TriggerContext {
@Nullable
private final Instant scheduled;
private final @Nullable Instant scheduled;
@Nullable
private final Instant actual;
private final @Nullable Instant actual;
@Nullable
private final Instant completion;
private final @Nullable Instant completion;
TestTriggerContext(@Nullable Instant scheduled,
@Nullable Instant actual, @Nullable Instant completion) {

View File

@@ -18,9 +18,10 @@ package org.springframework.scripting.groovy;
import java.lang.reflect.Method;
import org.jspecify.annotations.Nullable;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.lang.Nullable;
public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice {

View File

@@ -25,11 +25,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

View File

@@ -23,11 +23,11 @@ import java.util.Optional;
import java.util.Set;
import jakarta.validation.constraints.NotNull;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import static org.assertj.core.api.Assertions.assertThat;
@@ -211,8 +211,7 @@ class DataBinderConstructTests {
private final String param1;
@Nullable
private final DataClass nestedParam2;
private final @Nullable DataClass nestedParam2;
public NestedDataClass(String param1, @Nullable DataClass nestedParam2) {
this.param1 = param1;
@@ -223,8 +222,7 @@ class DataBinderConstructTests {
return this.param1;
}
@Nullable
public DataClass nestedParam2() {
public @Nullable DataClass nestedParam2() {
return this.nestedParam2;
}
}

View File

@@ -36,6 +36,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeanWrapper;
@@ -62,7 +63,6 @@ import org.springframework.format.Formatter;
import org.springframework.format.number.NumberStyleFormatter;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.BeanWithObjectProperty;
import org.springframework.util.StringUtils;

View File

@@ -32,6 +32,7 @@ import jakarta.validation.Payload;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Pattern;
import org.hibernate.validator.internal.constraintvalidators.bv.PatternValidator;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -45,7 +46,6 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RegisteredBean;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.OverridingClassLoader;
import org.springframework.lang.Nullable;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
@@ -150,8 +150,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
}
}
@Nullable
private BeanRegistrationAotContribution createContribution(Class<?> beanClass) {
private @Nullable BeanRegistrationAotContribution createContribution(Class<?> beanClass) {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition(beanClass.getName(), new RootBeanDefinition(beanClass));
return this.processor.processAheadOfTime(RegisteredBean.of(beanFactory, beanClass.getName()));

View File

@@ -25,10 +25,10 @@ import java.util.Optional;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.validation.FieldError;
import org.springframework.validation.method.MethodValidationResult;

View File

@@ -37,12 +37,12 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraintvalidation.SupportedValidationTarget;
import jakarta.validation.constraintvalidation.ValidationTarget;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.validation.FieldError;
import org.springframework.validation.method.MethodValidationResult;

View File

@@ -28,6 +28,7 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.Default;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@@ -42,7 +43,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncAnnotationAdvisor;
import org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor;
@@ -223,9 +223,8 @@ class MethodValidationProxyTests {
private final MyValidBean myValidBean = new MyValidBean();
@Nullable
@Override
public Object invoke(MethodInvocation invocation) {
public @Nullable Object invoke(MethodInvocation invocation) {
Method method;
try {
method = ClassUtils.getMethod(MyValidBean.class, invocation.getMethod().getName(), (Class<?>[]) null);