diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessor.java index 8e8058ea0ad3..3845006ed23b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorBeanRegistrationAotProcessor.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor; import org.springframework.beans.factory.aot.BeanRegistrationCode; import org.springframework.beans.factory.support.RegisteredBean; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -38,6 +39,7 @@ class AspectJAdvisorBeanRegistrationAotProcessor implements BeanRegistrationAotP @Override + @Nullable public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) { if (aspectjPresent) { Class beanClass = registeredBean.getBeanClass(); diff --git a/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java b/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java index 3a74eca980f9..f3adcd6a6718 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java @@ -23,6 +23,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.lang.Nullable; /** * {@link BeanDefinitionParser} responsible for parsing the @@ -51,6 +52,7 @@ class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser { @Override + @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) { RootBeanDefinition def = new RootBeanDefinition(); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java index 611a1bac8b9b..32d4c7e6bdb8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java @@ -270,6 +270,7 @@ public Object getEarlyBeanReference(Object bean, String beanName) { } @Override + @Nullable public Object postProcessBeforeInstantiation(Class beanClass, String beanName) { Object cacheKey = getCacheKey(beanClass, beanName); @@ -311,6 +312,7 @@ public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, Str * @see #getAdvicesAndAdvisorsForBean */ @Override + @Nullable public Object postProcessAfterInitialization(@Nullable Object bean, String beanName) { if (bean != null) { Object cacheKey = getCacheKey(bean.getClass(), beanName); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java index 823961064347..c9ea561366a4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java @@ -81,6 +81,7 @@ public void setBeanNames(String... beanNames) { * @see #setBeanNames(String...) */ @Override + @Nullable protected TargetSource getCustomTargetSource(Class beanClass, String beanName) { return (isSupportedBeanName(beanClass, beanName) ? super.getCustomTargetSource(beanClass, beanName) : null); diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyBeanRegistrationAotProcessor.java b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyBeanRegistrationAotProcessor.java index 63f40110c4bb..daf8ceaf939d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyBeanRegistrationAotProcessor.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyBeanRegistrationAotProcessor.java @@ -53,6 +53,7 @@ class ScopedProxyBeanRegistrationAotProcessor implements BeanRegistrationAotProc @Override + @Nullable public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) { Class beanClass = registeredBean.getBeanClass(); if (beanClass.equals(ScopedProxyFactoryBean.class)) { diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java index fe7934b0ca0c..a787a1ee809c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java @@ -117,6 +117,7 @@ public void setBeanFactory(BeanFactory beanFactory) { @Override + @Nullable public Object getObject() { if (this.proxy == null) { throw new FactoryBeanNotInitializedException(); @@ -125,6 +126,7 @@ public Object getObject() { } @Override + @Nullable public Class getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java b/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java index 10bcf80400bf..a07cae6d3b84 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java @@ -69,7 +69,7 @@ public BeanInstantiationException(Class beanClass, String msg, @Nullable Thro * @param cause the root cause * @since 4.3 */ - public BeanInstantiationException(Constructor constructor, String msg, @Nullable Throwable cause) { + public BeanInstantiationException(Constructor constructor, @Nullable String msg, @Nullable Throwable cause) { super("Failed to instantiate [" + constructor.getDeclaringClass().getName() + "]: " + msg, cause); this.beanClass = constructor.getDeclaringClass(); this.constructor = constructor; @@ -84,7 +84,7 @@ public BeanInstantiationException(Constructor constructor, String msg, @Nulla * @param cause the root cause * @since 4.3 */ - public BeanInstantiationException(Method constructingMethod, String msg, @Nullable Throwable cause) { + public BeanInstantiationException(Method constructingMethod, @Nullable String msg, @Nullable Throwable cause) { super("Failed to instantiate [" + constructingMethod.getReturnType().getName() + "]: " + msg, cause); this.beanClass = constructingMethod.getReturnType(); this.constructor = null; diff --git a/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java b/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java index 8a0af42cded8..327643cbbf3f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java @@ -18,6 +18,8 @@ import java.beans.PropertyChangeEvent; +import org.springframework.lang.Nullable; + /** * Thrown when a bean property getter or setter method throws an exception, * analogous to an InvocationTargetException. @@ -38,7 +40,7 @@ public class MethodInvocationException extends PropertyAccessException { * @param propertyChangeEvent the PropertyChangeEvent that resulted in an exception * @param cause the Throwable raised by the invoked method */ - public MethodInvocationException(PropertyChangeEvent propertyChangeEvent, Throwable cause) { + public MethodInvocationException(PropertyChangeEvent propertyChangeEvent, @Nullable Throwable cause) { super(propertyChangeEvent, "Property '" + propertyChangeEvent.getPropertyName() + "' threw exception", cause); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java index cac597c28ec7..9290a7153722 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java @@ -94,7 +94,7 @@ public BeanCreationException(String beanName, String msg, Throwable cause) { * @param beanName the name of the bean requested * @param msg the detail message */ - public BeanCreationException(@Nullable String resourceDescription, @Nullable String beanName, String msg) { + public BeanCreationException(@Nullable String resourceDescription, @Nullable String beanName, @Nullable String msg) { super("Error creating bean with name '" + beanName + "'" + (resourceDescription != null ? " defined in " + resourceDescription : "") + ": " + msg); this.resourceDescription = resourceDescription; @@ -110,7 +110,7 @@ public BeanCreationException(@Nullable String resourceDescription, @Nullable Str * @param msg the detail message * @param cause the root cause */ - public BeanCreationException(@Nullable String resourceDescription, String beanName, String msg, Throwable cause) { + public BeanCreationException(@Nullable String resourceDescription, String beanName, @Nullable String msg, Throwable cause) { this(resourceDescription, beanName, msg); initCause(cause); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java index 29c4b47349f8..d11a5a16f823 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java @@ -44,7 +44,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException { * @param msg the detail message */ public UnsatisfiedDependencyException( - @Nullable String resourceDescription, @Nullable String beanName, String propertyName, String msg) { + @Nullable String resourceDescription, @Nullable String beanName, String propertyName, @Nullable String msg) { super(resourceDescription, beanName, "Unsatisfied dependency expressed through bean property '" + propertyName + "'" + @@ -75,7 +75,7 @@ public UnsatisfiedDependencyException( * @since 4.3 */ public UnsatisfiedDependencyException( - @Nullable String resourceDescription, @Nullable String beanName, @Nullable InjectionPoint injectionPoint, String msg) { + @Nullable String resourceDescription, @Nullable String beanName, @Nullable InjectionPoint injectionPoint, @Nullable String msg) { super(resourceDescription, beanName, "Unsatisfied dependency expressed through " + injectionPoint + diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertyValueCodeGeneratorDelegates.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertyValueCodeGeneratorDelegates.java index f9cfc2ad00c5..c4188077839a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertyValueCodeGeneratorDelegates.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionPropertyValueCodeGeneratorDelegates.java @@ -37,6 +37,7 @@ import org.springframework.beans.factory.support.ManagedSet; import org.springframework.javapoet.AnnotationSpec; import org.springframework.javapoet.CodeBlock; +import org.springframework.lang.Nullable; /** * Code generator {@link Delegate} for common bean definition property values. @@ -101,6 +102,7 @@ private static class ManagedMapDelegate implements Delegate { private static final CodeBlock EMPTY_RESULT = CodeBlock.of("$T.ofEntries()", ManagedMap.class); @Override + @Nullable public CodeBlock generateCode(ValueCodeGenerator valueCodeGenerator, Object value) { if (value instanceof ManagedMap managedMap) { return generateManagedMapCode(valueCodeGenerator, managedMap); @@ -137,6 +139,7 @@ private CodeBlock generateManagedMapCode(ValueCodeGenerator valueCodeGene private static class LinkedHashMapDelegate extends MapDelegate { @Override + @Nullable protected CodeBlock generateMapCode(ValueCodeGenerator valueCodeGenerator, Map map) { GeneratedMethods generatedMethods = valueCodeGenerator.getGeneratedMethods(); if (map instanceof LinkedHashMap && generatedMethods != null) { @@ -172,6 +175,7 @@ private CodeBlock generateLinkedHashMapCode(ValueCodeGenerator valueCodeGenerato private static class BeanReferenceDelegate implements Delegate { @Override + @Nullable public CodeBlock generateCode(ValueCodeGenerator valueCodeGenerator, Object value) { if (value instanceof RuntimeBeanReference runtimeBeanReference && runtimeBeanReference.getBeanType() != null) { @@ -193,6 +197,7 @@ else if (value instanceof BeanReference beanReference) { private static class TypedStringValueDelegate implements Delegate { @Override + @Nullable public CodeBlock generateCode(ValueCodeGenerator valueCodeGenerator, Object value) { if (value instanceof TypedStringValue typedStringValue) { return generateTypeStringValueCode(valueCodeGenerator, typedStringValue); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java index 7715f33faa6b..4550843e3654 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java @@ -151,6 +151,7 @@ public void afterPropertiesSet() throws Exception { * @see #getEarlySingletonInterfaces() */ @Override + @Nullable public final T getObject() throws Exception { if (isSingleton()) { return (this.initialized ? this.singletonInstance : getEarlySingletonInstance()); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index 9f7657f196c4..86b6ccc23471 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java @@ -226,6 +226,7 @@ public Object getObject() throws IllegalAccessException { } @Override + @Nullable public Class getObjectType() { return (this.fieldObject != null ? this.fieldObject.getType() : null); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java index 3ff39d81e5e3..ec89f904e4f4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java @@ -136,6 +136,7 @@ public Object getObject() throws Exception { * or {@code null} if not known in advance. */ @Override + @Nullable public Class getObjectType() { if (!isPrepared()) { // Not fully initialized yet -> return null to indicate "not known yet". diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java index b86e633f744f..348b4674b7aa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java @@ -224,6 +224,7 @@ public Object getObject() throws BeansException { } @Override + @Nullable public Class getObjectType() { return this.resultType; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java index 8d0cf7dd397e..590280998d59 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java @@ -335,6 +335,7 @@ public Object getObject() { } @Override + @Nullable public Class getObjectType() { return this.serviceLocatorInterface; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java index b3da7fb62b44..551e0050a9ff 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java @@ -241,6 +241,7 @@ public LookupOverrideMethodInterceptor(RootBeanDefinition beanDefinition, BeanFa } @Override + @Nullable public Object intercept(Object obj, Method method, Object[] args, MethodProxy mp) throws Throwable { // Cast is safe, as CallbackFilter filters are used selectively. LookupOverride lo = (LookupOverride) getBeanDefinition().getMethodOverrides().getOverride(method); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 4670ac1f8295..45b15772f014 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -1434,6 +1434,7 @@ public boolean hasShortcut() { } @Override + @Nullable public Object resolveShortcut(BeanFactory beanFactory) { String shortcut = this.shortcut; return (shortcut != null ? beanFactory.getBean(shortcut, getDependencyType()) : null); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java index 35ca8470e2b7..14198c4b2f1f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java @@ -342,7 +342,7 @@ else if (!reactiveStreamsPresent || !new ReactiveDestroyMethodHandler().await(de } } - void logDestroyMethodException(Method destroyMethod, Throwable ex) { + void logDestroyMethodException(Method destroyMethod, @Nullable Throwable ex) { if (logger.isWarnEnabled()) { String msg = "Custom destroy method '" + destroyMethod.getName() + "' on bean with name '" + this.beanName + "' propagated an exception"; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/InstanceSupplier.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/InstanceSupplier.java index 8d930b357395..22e65bc12be5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/InstanceSupplier.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/InstanceSupplier.java @@ -83,6 +83,7 @@ public V get(RegisteredBean registeredBean) throws Exception { return after.applyWithException(registeredBean, InstanceSupplier.this.get(registeredBean)); } @Override + @Nullable public Method getFactoryMethod() { return InstanceSupplier.this.getFactoryMethod(); } @@ -126,6 +127,7 @@ public T get(RegisteredBean registeredBean) throws Exception { return supplier.getWithException(); } @Override + @Nullable public Method getFactoryMethod() { return factoryMethod; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java index ccdc1e1454ec..feae33613fb6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java @@ -277,6 +277,7 @@ public RootBeanDefinition(RootBeanDefinition original) { @Override + @Nullable public String getParentName() { return null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java index 4fded794a043..e93b7da2e359 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java @@ -232,11 +232,13 @@ public boolean isTypeMatch(String name, @Nullable Class typeToMatch) throws N } @Override + @Nullable public Class getType(String name) throws NoSuchBeanDefinitionException { return getType(name, true); } @Override + @Nullable public Class getType(String name, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException { String beanName = BeanFactoryUtils.transformedBeanName(name); diff --git a/spring-core/src/main/java/org/springframework/util/MethodInvoker.java b/spring-core/src/main/java/org/springframework/util/MethodInvoker.java index 0443c5699ca1..795922f5ab0e 100644 --- a/spring-core/src/main/java/org/springframework/util/MethodInvoker.java +++ b/spring-core/src/main/java/org/springframework/util/MethodInvoker.java @@ -136,7 +136,7 @@ public void setStaticMethod(String staticMethod) { * Set arguments for the method invocation. If this property is not set, * or the Object array is of length 0, a method with no arguments is assumed. */ - public void setArguments(Object... arguments) { + public void setArguments(@Nullable Object... arguments) { this.arguments = arguments; } diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index 620ed51b62e7..4d1af9d2175d 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -137,7 +137,7 @@ public static void handleInvocationTargetException(InvocationTargetException ex) * @param ex the exception to rethrow * @throws RuntimeException the rethrown exception */ - public static void rethrowRuntimeException(Throwable ex) { + public static void rethrowRuntimeException(@Nullable Throwable ex) { if (ex instanceof RuntimeException runtimeException) { throw runtimeException; } @@ -158,7 +158,7 @@ public static void rethrowRuntimeException(Throwable ex) { * @param throwable the exception to rethrow * @throws Exception the rethrown exception (in case of a checked exception) */ - public static void rethrowException(Throwable throwable) throws Exception { + public static void rethrowException(@Nullable Throwable throwable) throws Exception { if (throwable instanceof Exception exception) { throw exception; } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java index 665cfa8bdb21..eb0eb0f184e5 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/BadSqlGrammarException.java @@ -19,6 +19,7 @@ import java.sql.SQLException; import org.springframework.dao.InvalidDataAccessResourceUsageException; +import org.springframework.lang.Nullable; /** * Exception thrown when SQL specified is invalid. Such exceptions always have @@ -52,6 +53,7 @@ public BadSqlGrammarException(String task, String sql, SQLException ex) { /** * Return the wrapped SQLException. */ + @Nullable public SQLException getSQLException() { return (SQLException) getCause(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java index 122d7b28e3f6..d671af15f7a6 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/InvalidResultSetAccessException.java @@ -64,6 +64,7 @@ public InvalidResultSetAccessException(SQLException ex) { /** * Return the wrapped SQLException. */ + @Nullable public SQLException getSQLException() { return (SQLException) getCause(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/SQLWarningException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/SQLWarningException.java index 87785189d888..2019b2ebd2f9 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/SQLWarningException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/SQLWarningException.java @@ -19,6 +19,7 @@ import java.sql.SQLWarning; import org.springframework.dao.UncategorizedDataAccessException; +import org.springframework.lang.Nullable; /** * Exception thrown when we're not ignoring {@link java.sql.SQLWarning SQLWarnings}. @@ -49,6 +50,7 @@ public SQLWarningException(String msg, SQLWarning ex) { * Return the underlying {@link SQLWarning}. * @since 5.3.29 */ + @Nullable public SQLWarning getSQLWarning() { return (SQLWarning) getCause(); } @@ -58,6 +60,7 @@ public SQLWarning getSQLWarning() { * @deprecated as of 5.3.29, in favor of {@link #getSQLWarning()} */ @Deprecated(since = "5.3.29") + @Nullable public SQLWarning SQLWarning() { return getSQLWarning(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/UncategorizedSQLException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/UncategorizedSQLException.java index 315a6f9bd015..897acfbdbdb6 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/UncategorizedSQLException.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/UncategorizedSQLException.java @@ -53,6 +53,7 @@ public UncategorizedSQLException(String task, @Nullable String sql, SQLException /** * Return the underlying SQLException. */ + @Nullable public SQLException getSQLException() { return (SQLException) getCause(); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index 699c15f0f049..aad9bc354286 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -907,11 +907,13 @@ public T queryForObject(String sql, Object[] args, int[] argTypes, Class @Deprecated @Override + @Nullable public T queryForObject(String sql, @Nullable Object[] args, Class requiredType) throws DataAccessException { return queryForObject(sql, args, getSingleColumnRowMapper(requiredType)); } @Override + @Nullable public T queryForObject(String sql, Class requiredType, @Nullable Object... args) throws DataAccessException { return queryForObject(sql, args, getSingleColumnRowMapper(requiredType)); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/AbstractDataFieldMaxValueIncrementer.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/AbstractDataFieldMaxValueIncrementer.java index 75bb69ea9cb3..8049e868edda 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/AbstractDataFieldMaxValueIncrementer.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/AbstractDataFieldMaxValueIncrementer.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.dao.DataAccessException; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -34,9 +35,11 @@ */ public abstract class AbstractDataFieldMaxValueIncrementer implements DataFieldMaxValueIncrementer, InitializingBean { + @Nullable private DataSource dataSource; /** The name of the sequence/table containing the sequence. */ + @Nullable private String incrementerName; /** The length to which a string result should be pre-pended with zeroes. */ diff --git a/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java b/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java index e7a6727de232..4598ddf9af28 100644 --- a/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java +++ b/spring-orm/src/main/java/org/springframework/orm/ObjectOptimisticLockingFailureException.java @@ -42,7 +42,7 @@ public class ObjectOptimisticLockingFailureException extends OptimisticLockingFa * @param msg the detail message * @param cause the source exception */ - public ObjectOptimisticLockingFailureException(String msg, Throwable cause) { + public ObjectOptimisticLockingFailureException(@Nullable String msg, Throwable cause) { super(msg, cause); this.persistentClass = null; this.identifier = null; @@ -123,7 +123,7 @@ public ObjectOptimisticLockingFailureException( * @param cause the source exception */ public ObjectOptimisticLockingFailureException( - String persistentClassName, @Nullable Object identifier, String msg, @Nullable Throwable cause) { + String persistentClassName, @Nullable Object identifier, @Nullable String msg, @Nullable Throwable cause) { super(msg, cause); this.persistentClass = persistentClassName; diff --git a/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java b/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java index 93137c977536..54536f5d5705 100644 --- a/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java +++ b/spring-orm/src/main/java/org/springframework/orm/ObjectRetrievalFailureException.java @@ -42,7 +42,7 @@ public class ObjectRetrievalFailureException extends DataRetrievalFailureExcepti * @param msg the detail message * @param cause the source exception */ - public ObjectRetrievalFailureException(String msg, Throwable cause) { + public ObjectRetrievalFailureException(@Nullable String msg, Throwable cause) { super(msg, cause); this.persistentClass = null; this.identifier = null; @@ -97,7 +97,7 @@ public ObjectRetrievalFailureException(String persistentClassName, Object identi * @param cause the source exception */ public ObjectRetrievalFailureException( - String persistentClassName, @Nullable Object identifier, String msg, @Nullable Throwable cause) { + String persistentClassName, @Nullable Object identifier, @Nullable String msg, @Nullable Throwable cause) { super(msg, cause); this.persistentClass = persistentClassName; diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateJdbcException.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateJdbcException.java index bee09d4485cc..1f02fdb299ad 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateJdbcException.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateJdbcException.java @@ -21,6 +21,7 @@ import org.hibernate.JDBCException; import org.springframework.dao.UncategorizedDataAccessException; +import org.springframework.lang.Nullable; /** * Hibernate-specific subclass of UncategorizedDataAccessException, @@ -48,6 +49,7 @@ public SQLException getSQLException() { /** * Return the SQL that led to the problem. */ + @Nullable public String getSql() { return ((JDBCException) getCause()).getSQL(); } diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateQueryException.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateQueryException.java index 5d3a61ae0e59..edd4d665dd14 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateQueryException.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateQueryException.java @@ -19,6 +19,7 @@ import org.hibernate.QueryException; import org.springframework.dao.InvalidDataAccessResourceUsageException; +import org.springframework.lang.Nullable; /** * Hibernate-specific subclass of InvalidDataAccessResourceUsageException, @@ -38,6 +39,7 @@ public HibernateQueryException(QueryException ex) { /** * Return the HQL query string that was invalid. */ + @Nullable public String getQueryString() { return ((QueryException) getCause()).getQueryString(); } diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/support/AsyncRequestInterceptor.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/support/AsyncRequestInterceptor.java index 3602dac266e5..14edcf28026f 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/support/AsyncRequestInterceptor.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/support/AsyncRequestInterceptor.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.SessionFactory; +import org.springframework.lang.Nullable; import org.springframework.orm.hibernate5.SessionFactoryUtils; import org.springframework.orm.hibernate5.SessionHolder; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -72,7 +73,7 @@ public void bindSession() { } @Override - public void postProcess(NativeWebRequest request, Callable task, Object concurrentResult) { + public void postProcess(NativeWebRequest request, Callable task, @Nullable Object concurrentResult) { TransactionSynchronizationManager.unbindResource(this.sessionFactory); } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java b/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java index 46efcd21cb75..3bee08ed148e 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.lang.Nullable; import org.springframework.orm.jpa.EntityManagerFactoryUtils; import org.springframework.orm.jpa.EntityManagerHolder; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -72,7 +73,7 @@ public void bindEntityManager() { } @Override - public void postProcess(NativeWebRequest request, Callable task, Object concurrentResult) { + public void postProcess(NativeWebRequest request, Callable task, @Nullable Object concurrentResult) { TransactionSynchronizationManager.unbindResource(this.emFactory); } diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/BadSqlGrammarException.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/BadSqlGrammarException.java index b2b619eb4ebc..84effd5a8f25 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/BadSqlGrammarException.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/BadSqlGrammarException.java @@ -19,6 +19,7 @@ import io.r2dbc.spi.R2dbcException; import org.springframework.dao.InvalidDataAccessResourceUsageException; +import org.springframework.lang.Nullable; /** * Exception thrown when SQL specified is invalid. Such exceptions always have a @@ -52,6 +53,7 @@ public BadSqlGrammarException(String task, String sql, R2dbcException ex) { /** * Return the wrapped {@link R2dbcException}. */ + @Nullable public R2dbcException getR2dbcException() { return (R2dbcException) getCause(); } diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/UncategorizedR2dbcException.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/UncategorizedR2dbcException.java index 2944f01f3a46..3c0b6acfa709 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/UncategorizedR2dbcException.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/UncategorizedR2dbcException.java @@ -51,6 +51,7 @@ public UncategorizedR2dbcException(String msg, @Nullable String sql, R2dbcExcept /** * Return the wrapped {@link R2dbcException}. */ + @Nullable public R2dbcException getR2dbcException() { return (R2dbcException) getCause(); } diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java index 93592d3ad1ff..d7dd814f6e3c 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java @@ -448,6 +448,7 @@ private record ExtendedTransactionDefinition(@Nullable String transactionName, @SuppressWarnings("unchecked") @Override + @Nullable public T getAttribute(Option option) { return (T) doGetValue(option); } diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java index 31fc1ef9a198..0175c0b1c3ca 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java @@ -129,6 +129,7 @@ static class BuiltInBindMarkersFactoryProvider implements BindMarkerFactoryProvi @Override + @Nullable public BindMarkersFactory getBindMarkers(ConnectionFactory connectionFactory) { ConnectionFactoryMetadata metadata = connectionFactory.getMetadata(); BindMarkersFactory r2dbcDialect = BUILTIN.get(metadata.getName());