From 0e85d950b3761dc79a8d6fbef22293cb3c919517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Wed, 18 Dec 2024 18:22:54 +0100 Subject: [PATCH] Remove unneeded `@NonNull` annotations See gh-28797 --- .../org/springframework/beans/SimpleBeanInfoFactory.java | 4 +--- .../org/springframework/beans/StandardBeanInfoFactory.java | 4 +--- .../factory/support/BeanDefinitionOverrideException.java | 6 ++---- .../annotation/ConfigurationClassBeanDefinitionReader.java | 3 +-- .../scheduling/annotation/AsyncConfigurationSelector.java | 4 +--- .../org/springframework/validation/MapBindingResult.java | 3 +-- .../springframework/core/annotation/AnnotatedMethod.java | 3 +-- .../core/namedparam/BeanPropertySqlParameterSource.java | 3 +-- .../jdbc/core/namedparam/MapSqlParameterSource.java | 3 +-- .../org/springframework/r2dbc/core/binding/Bindings.java | 3 +-- .../org/springframework/mock/web/MockMultipartFile.java | 3 +-- .../springframework/http/client/MultipartBodyBuilder.java | 3 +-- .../org/springframework/http/codec/xml/Jaxb2XmlDecoder.java | 3 +-- .../http/server/reactive/ServletServerHttpRequest.java | 5 ++--- .../springframework/web/util/HierarchicalUriComponents.java | 3 +-- .../web/testfixture/servlet/MockMultipartFile.java | 3 +-- 16 files changed, 18 insertions(+), 38 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java b/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java index 554298e03af..45f1b09cd89 100644 --- a/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/SimpleBeanInfoFactory.java @@ -23,8 +23,6 @@ import java.beans.SimpleBeanInfo; import java.util.Collection; -import org.jspecify.annotations.NonNull; - import org.springframework.core.Ordered; /** @@ -48,7 +46,7 @@ class SimpleBeanInfoFactory implements BeanInfoFactory, Ordered { @Override - public @NonNull BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { + public BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { Collection pds = PropertyDescriptorUtils.determineBasicProperties(beanClass); diff --git a/spring-beans/src/main/java/org/springframework/beans/StandardBeanInfoFactory.java b/spring-beans/src/main/java/org/springframework/beans/StandardBeanInfoFactory.java index 86905474290..feda722741f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/StandardBeanInfoFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/StandardBeanInfoFactory.java @@ -20,8 +20,6 @@ import java.beans.IntrospectionException; import java.beans.Introspector; -import org.jspecify.annotations.NonNull; - import org.springframework.core.Ordered; import org.springframework.core.SpringProperties; @@ -67,7 +65,7 @@ public class StandardBeanInfoFactory implements BeanInfoFactory, Ordered { @Override - public @NonNull BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { + public BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { BeanInfo beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ? Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) : Introspector.getBeanInfo(beanClass)); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionOverrideException.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionOverrideException.java index 0a5ac2cec49..6ccc96a08af 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionOverrideException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionOverrideException.java @@ -16,8 +16,6 @@ package org.springframework.beans.factory.support; -import org.jspecify.annotations.NonNull; - import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.config.BeanDefinition; @@ -76,7 +74,7 @@ public BeanDefinitionOverrideException( * Return the description of the resource that the bean definition came from. */ @Override - public @NonNull String getResourceDescription() { + public String getResourceDescription() { return String.valueOf(super.getResourceDescription()); } @@ -84,7 +82,7 @@ public BeanDefinitionOverrideException( * Return the name of the bean. */ @Override - public @NonNull String getBeanName() { + public String getBeanName() { return String.valueOf(super.getBeanName()); } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java index 1775d7de294..6cf226bdefc 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java @@ -26,7 +26,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.jspecify.annotations.NonNull; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; @@ -448,7 +447,7 @@ public AnnotationMetadata getMetadata() { } @Override - public @NonNull MethodMetadata getFactoryMethodMetadata() { + public MethodMetadata getFactoryMethodMetadata() { return this.factoryMethodMetadata; } diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java index a69a43b561b..4f81076993d 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java @@ -16,8 +16,6 @@ package org.springframework.scheduling.annotation; -import org.jspecify.annotations.NonNull; - import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.AdviceModeImportSelector; @@ -44,7 +42,7 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector new String[] {ProxyAsyncConfiguration.class.getName()}; case ASPECTJ -> new String[] {ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME}; diff --git a/spring-context/src/main/java/org/springframework/validation/MapBindingResult.java b/spring-context/src/main/java/org/springframework/validation/MapBindingResult.java index f15a1ae7b5a..6739dd27f32 100644 --- a/spring-context/src/main/java/org/springframework/validation/MapBindingResult.java +++ b/spring-context/src/main/java/org/springframework/validation/MapBindingResult.java @@ -19,7 +19,6 @@ import java.io.Serializable; import java.util.Map; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -62,7 +61,7 @@ public MapBindingResult(Map target, String objectName) { } @Override - public final @NonNull Object getTarget() { + public final Object getTarget() { return this.target; } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java index a7e24d5c119..b2578a4a733 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.List; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.core.BridgeMethodResolver; @@ -264,7 +263,7 @@ protected AnnotatedMethodParameter(AnnotatedMethodParameter original) { } @Override - public @NonNull Method getMethod() { + public Method getMethod() { return AnnotatedMethod.this.getBridgedMethod(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java index 4eb53d85413..f3fdc3f67d9 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.beans.BeanWrapper; @@ -90,7 +89,7 @@ public int getSqlType(String paramName) { } @Override - public @NonNull String[] getParameterNames() { + public String[] getParameterNames() { return getReadablePropertyNames(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java index b7bd54ed698..92ab173f4f1 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java @@ -20,7 +20,6 @@ import java.util.LinkedHashMap; import java.util.Map; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.jdbc.core.SqlParameterValue; @@ -174,7 +173,7 @@ public boolean hasValue(String paramName) { } @Override - public @NonNull String[] getParameterNames() { + public String[] getParameterNames() { return StringUtils.toStringArray(this.values.keySet()); } diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java index 445a46df220..36dd071e45a 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java @@ -26,7 +26,6 @@ import java.util.function.Consumer; import io.r2dbc.spi.Statement; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -206,7 +205,7 @@ public boolean hasValue() { } @Override - public @NonNull Object getValue() { + public Object getValue() { return this.value; } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartFile.java b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartFile.java index cc4834d49a5..af99ed513ed 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartFile.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartFile.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -109,7 +108,7 @@ public String getName() { } @Override - public @NonNull String getOriginalFilename() { + public String getOriginalFilename() { return this.originalFilename; } diff --git a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java index 80842db21f9..01223b32fa8 100644 --- a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.function.Consumer; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.reactivestreams.Publisher; @@ -379,7 +378,7 @@ static final class PublisherEntity> extends HttpEntity * Return the element type for the {@code Publisher} body. */ @Override - public @NonNull ResolvableType getResolvableType() { + public ResolvableType getResolvableType() { return this.resolvableType; } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java index 100b2cef653..91bb718289e 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java @@ -37,7 +37,6 @@ import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlSeeAlso; import jakarta.xml.bind.annotation.XmlType; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.reactivestreams.Publisher; import reactor.core.Exceptions; @@ -172,7 +171,7 @@ public Mono decodeToMono(Publisher input, ResolvableType ele } @Override - public @NonNull Object decode(DataBuffer dataBuffer, ResolvableType targetType, + public Object decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map hints) throws DecodingException { try { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java index c361c566f98..a5bd9df508b 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java @@ -35,7 +35,6 @@ import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import reactor.core.publisher.Flux; @@ -214,12 +213,12 @@ protected MultiValueMap initCookies() { } @Override - public @NonNull InetSocketAddress getLocalAddress() { + public InetSocketAddress getLocalAddress() { return new InetSocketAddress(this.request.getLocalAddr(), this.request.getLocalPort()); } @Override - public @NonNull InetSocketAddress getRemoteAddress() { + public InetSocketAddress getRemoteAddress() { return new InetSocketAddress(this.request.getRemoteHost(), this.request.getRemotePort()); } diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 02ccc8a9ca4..65457686bde 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -29,7 +29,6 @@ import java.util.function.BiFunction; import java.util.function.UnaryOperator; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -196,7 +195,7 @@ else if (this.port.contains("{")) { } @Override - public @NonNull String getPath() { + public String getPath() { return this.path.getPath(); } diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java index 3a55a9c504b..4f22690252d 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockMultipartFile.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -109,7 +108,7 @@ public String getName() { } @Override - public @NonNull String getOriginalFilename() { + public String getOriginalFilename() { return this.originalFilename; }