diff --git a/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java index e69a01842e00..746a317f5771 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java @@ -65,6 +65,7 @@ public class LazyInitTargetSource extends AbstractBeanFactoryBasedTargetSource { @Override + @Nullable public synchronized Object getTarget() throws BeansException { if (this.target == null) { this.target = getBeanFactory().getBean(getTargetBeanName()); diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java index e4feb09554ba..0e87c8af53ad 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java @@ -121,6 +121,7 @@ protected Collection loadCaches() { } @Override + @Nullable protected Cache getMissingCache(String name) { CacheManager cacheManager = getCacheManager(); Assert.state(cacheManager != null, "No CacheManager set"); diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java index ba7b5d8e9c19..82db7a9a6ac9 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java @@ -46,6 +46,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJCacheOperationSource { @Override + @Nullable protected JCacheOperation findCacheOperation(Method method, @Nullable Class targetType) { CacheResult cacheResult = method.getAnnotation(CacheResult.class); CachePut cachePut = method.getAnnotation(CachePut.class); diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java index d71af3244dba..f64c09a336f1 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutInterceptor.java @@ -23,6 +23,7 @@ import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.CacheOperationInvocationContext; import org.springframework.cache.interceptor.CacheOperationInvoker; +import org.springframework.lang.Nullable; /** * Intercept methods annotated with {@link CachePut}. @@ -39,6 +40,7 @@ public CachePutInterceptor(CacheErrorHandler errorHandler) { @Override + @Nullable protected Object invoke( CacheOperationInvocationContext context, CacheOperationInvoker invoker) { diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllInterceptor.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllInterceptor.java index 66b583e37870..dfd8f0a4cc0e 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllInterceptor.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllInterceptor.java @@ -22,6 +22,7 @@ import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.CacheOperationInvocationContext; import org.springframework.cache.interceptor.CacheOperationInvoker; +import org.springframework.lang.Nullable; /** * Intercept methods annotated with {@link CacheRemoveAll}. @@ -38,6 +39,7 @@ protected CacheRemoveAllInterceptor(CacheErrorHandler errorHandler) { @Override + @Nullable protected Object invoke( CacheOperationInvocationContext context, CacheOperationInvoker invoker) { diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveEntryInterceptor.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveEntryInterceptor.java index 84852783166a..a1075785bb24 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveEntryInterceptor.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveEntryInterceptor.java @@ -22,6 +22,7 @@ import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.CacheOperationInvocationContext; import org.springframework.cache.interceptor.CacheOperationInvoker; +import org.springframework.lang.Nullable; /** * Intercept methods annotated with {@link CacheRemove}. @@ -38,6 +39,7 @@ protected CacheRemoveEntryInterceptor(CacheErrorHandler errorHandler) { @Override + @Nullable protected Object invoke( CacheOperationInvocationContext context, CacheOperationInvoker invoker) { diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java index 1dbf3c8ae6d4..de1ff1a293af 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java @@ -180,6 +180,7 @@ public CacheOperationInvokerAdapter(CacheOperationInvoker delegate) { } @Override + @Nullable public Object invoke() throws ThrowableWrapper { return invokeOperation(this.delegate); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/SimpleExceptionCacheResolver.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/SimpleExceptionCacheResolver.java index 1aa569546131..70eca3aad5e3 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/SimpleExceptionCacheResolver.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/SimpleExceptionCacheResolver.java @@ -24,6 +24,7 @@ import org.springframework.cache.interceptor.BasicOperation; import org.springframework.cache.interceptor.CacheOperationInvocationContext; import org.springframework.cache.interceptor.CacheResolver; +import org.springframework.lang.Nullable; /** * A simple {@link CacheResolver} that resolves the exception cache @@ -41,6 +42,7 @@ public SimpleExceptionCacheResolver(CacheManager cacheManager) { } @Override + @Nullable protected Collection getCacheNames(CacheOperationInvocationContext context) { BasicOperation operation = context.getOperation(); if (!(operation instanceof CacheResultOperation cacheResultOperation)) { diff --git a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java index 1c14c85a4b89..45b5870dfecc 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java +++ b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java @@ -83,6 +83,7 @@ public ValueWrapper get(Object key) { } @Override + @Nullable public T get(Object key, @Nullable Class type) { return this.targetCache.get(key, type); } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java index cace9ab82e4b..d692c4bf74f8 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java @@ -199,6 +199,7 @@ protected void postProcessJobDetail(JobDetail jobDetail) { * Overridden to support the {@link #setTargetBeanName "targetBeanName"} feature. */ @Override + @Nullable public Class getTargetClass() { Class targetClass = super.getTargetClass(); if (targetClass == null && this.targetBeanName != null) { @@ -212,6 +213,7 @@ public Class getTargetClass() { * Overridden to support the {@link #setTargetBeanName "targetBeanName"} feature. */ @Override + @Nullable public Object getTargetObject() { Object targetObject = super.getTargetObject(); if (targetObject == null && this.targetBeanName != null) { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHints.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHints.java index c2d727a45588..811c8eaab420 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHints.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHints.java @@ -22,6 +22,7 @@ import org.springframework.aot.hint.TypeHint.Builder; import org.springframework.aot.hint.TypeReference; import org.springframework.aot.hint.annotation.ReflectiveRuntimeHintsRegistrar; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -40,7 +41,7 @@ class SchedulerFactoryBeanRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { if (!ClassUtils.isPresent(SCHEDULER_FACTORY_CLASS_NAME, classLoader)) { return; } diff --git a/spring-context/src/main/java/org/springframework/cache/Cache.java b/spring-context/src/main/java/org/springframework/cache/Cache.java index 0d8b352ff264..3df983a9a268 100644 --- a/spring-context/src/main/java/org/springframework/cache/Cache.java +++ b/spring-context/src/main/java/org/springframework/cache/Cache.java @@ -315,7 +315,7 @@ class ValueRetrievalException extends RuntimeException { @Nullable private final Object key; - public ValueRetrievalException(@Nullable Object key, Callable loader, Throwable ex) { + public ValueRetrievalException(@Nullable Object key, Callable loader, @Nullable Throwable ex) { super(String.format("Value for key '%s' could not be loaded using '%s'", key, loader), ex); this.key = key; } diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java index e3019f466cdc..0facea830e29 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java @@ -223,6 +223,7 @@ protected Object toStoreValue(@Nullable Object userValue) { } @Override + @Nullable protected Object fromStoreValue(@Nullable Object storeValue) { if (storeValue != null && this.serialization != null) { try { diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java index a8023cea59cb..61cfc4b469db 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java @@ -52,6 +52,7 @@ public void setCacheNames(Collection cacheNames) { } @Override + @Nullable protected Collection getCacheNames(CacheOperationInvocationContext context) { return this.cacheNames; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index e8de3b323d5b..15f044bbc398 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -314,6 +314,7 @@ public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, C } @Override + @Nullable public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) { BeanRegistrationAotContribution parentAotContribution = super.processAheadOfTime(registeredBean); Class beanClass = registeredBean.getBeanClass(); @@ -350,6 +351,7 @@ public void resetBeanDefinition(String beanName) { } @Override + @Nullable public Object postProcessBeforeInstantiation(Class beanClass, String beanName) { return null; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java index 73a922b7cf8f..4d487d2b5737 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java @@ -334,6 +334,7 @@ public Object intercept(Object enhancedConfigInstance, Method beanMethod, Object return resolveBeanReference(beanMethod, beanMethodArgs, beanFactory, beanName); } + @Nullable private Object resolveBeanReference(Method beanMethod, Object[] beanMethodArgs, ConfigurableBeanFactory beanFactory, String beanName) { diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index 9a2c88ced17f..1c86b5646c4e 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -350,7 +350,7 @@ protected void handleAsyncError(Throwable t) { * Invoke the event listener method with the given argument values. */ @Nullable - protected Object doInvoke(Object... args) { + protected Object doInvoke(@Nullable Object... args) { Object bean = getTargetBean(); // Detect package-protected NullBean instance through equals(null) check if (bean.equals(null)) { @@ -416,8 +416,8 @@ protected String getCondition() { * the given error message. * @param message error message to append the HandlerMethod details to */ - protected String getDetailedErrorMessage(Object bean, String message) { - StringBuilder sb = new StringBuilder(message).append('\n'); + protected String getDetailedErrorMessage(Object bean, @Nullable String message) { + StringBuilder sb = (StringUtils.hasLength(message) ? new StringBuilder(message).append('\n') : new StringBuilder()); sb.append("HandlerMethod details: \n"); sb.append("Bean [").append(bean.getClass().getName()).append("]\n"); sb.append("Method [").append(this.method.toGenericString()).append("]\n"); @@ -431,7 +431,7 @@ protected String getDetailedErrorMessage(Object bean, String message) { * beans, and others). Event listener beans that require proxying should prefer * class-based proxy mechanisms. */ - private void assertTargetBean(Method method, Object targetBean, Object[] args) { + private void assertTargetBean(Method method, Object targetBean, @Nullable Object[] args) { Class methodDeclaringClass = method.getDeclaringClass(); Class targetBeanClass = targetBean.getClass(); if (!methodDeclaringClass.isAssignableFrom(targetBeanClass)) { @@ -443,7 +443,7 @@ private void assertTargetBean(Method method, Object targetBean, Object[] args) { } } - private String getInvocationErrorMessage(Object bean, String message, Object[] resolvedArgs) { + private String getInvocationErrorMessage(Object bean, @Nullable String message, @Nullable Object[] resolvedArgs) { StringBuilder sb = new StringBuilder(getDetailedErrorMessage(bean, message)); sb.append("Resolved arguments: \n"); for (int i = 0; i < resolvedArgs.length; i++) { diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 2f5cbce333d2..6036342c6c8b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -1463,6 +1463,7 @@ protected BeanFactory getInternalParentBeanFactory() { //--------------------------------------------------------------------- @Override + @Nullable public String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) { return getMessageSource().getMessage(code, args, defaultMessage, locale); } diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java index d58ceadb5132..2f3840ed486a 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java @@ -137,6 +137,7 @@ protected boolean isUseCodeAsDefaultMessage() { @Override + @Nullable public final String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) { String msg = getMessageInternal(code, args, locale); if (msg != null) { diff --git a/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java b/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java index 998d061ca2cd..525d916ca0c5 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java +++ b/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java @@ -123,6 +123,7 @@ protected boolean isEligibleForOverriding(String className) { } @Override + @Nullable protected Class loadClassForOverriding(String name) throws ClassNotFoundException { byte[] bytes = bytesCache.get(name); if (bytes == null) { diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java index 3acaa0380869..a254cbd9fa76 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java @@ -191,6 +191,7 @@ public void setResourceLoader(@Nullable ResourceLoader resourceLoader) { * returning the value found in the bundle as-is (without MessageFormat parsing). */ @Override + @Nullable protected String resolveCodeWithoutArguments(String code, Locale locale) { if (getCacheMillis() < 0) { PropertiesHolder propHolder = getMergedProperties(locale); diff --git a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java index 012237889a49..026977b4fe2c 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java @@ -145,6 +145,7 @@ public void setBeanClassLoader(ClassLoader classLoader) { * returning the value found in the bundle as-is (without MessageFormat parsing). */ @Override + @Nullable protected String resolveCodeWithoutArguments(String code, Locale locale) { Set basenames = getBasenameSet(); for (String basename : basenames) { diff --git a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceRuntimeHints.java b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceRuntimeHints.java index a6e87cec0ca8..d1f41d84fcb3 100644 --- a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceRuntimeHints.java +++ b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceRuntimeHints.java @@ -19,6 +19,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; +import org.springframework.lang.Nullable; /** * {@link RuntimeHintsRegistrar} to register hints for {@link DefaultFormattingConversionService}. @@ -29,7 +30,7 @@ class FormattingConversionServiceRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { hints.reflection().registerType(TypeReference.of("javax.money.MonetaryAmount")); } } diff --git a/spring-context/src/main/java/org/springframework/jmx/access/InvalidInvocationException.java b/spring-context/src/main/java/org/springframework/jmx/access/InvalidInvocationException.java index ea16a2fed873..2cd42366d217 100644 --- a/spring-context/src/main/java/org/springframework/jmx/access/InvalidInvocationException.java +++ b/spring-context/src/main/java/org/springframework/jmx/access/InvalidInvocationException.java @@ -18,6 +18,8 @@ import javax.management.JMRuntimeException; +import org.springframework.lang.Nullable; + /** * Thrown when trying to invoke an operation on a proxy that is not exposed * by the proxied MBean resource's management interface. @@ -35,7 +37,7 @@ public class InvalidInvocationException extends JMRuntimeException { * error message. * @param msg the detail message */ - public InvalidInvocationException(String msg) { + public InvalidInvocationException(@Nullable String msg) { super(msg); } diff --git a/spring-context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java b/spring-context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java index 0acc722b261f..b0c62aa13a17 100644 --- a/spring-context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/jmx/access/MBeanProxyFactoryBean.java @@ -108,6 +108,7 @@ public Object getObject() { } @Override + @Nullable public Class getObjectType() { return this.proxyInterface; } diff --git a/spring-context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java b/spring-context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java index a237e6c731ef..b56ce01e0bca 100644 --- a/spring-context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java @@ -273,6 +273,7 @@ public Object getObject() { } @Override + @Nullable public Class getObjectType() { if (this.proxyInterfaces != null) { if (this.proxyInterfaces.length == 1) { diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurerSupport.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurerSupport.java index bf7a2d0baf63..4c1e83146873 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurerSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurerSupport.java @@ -34,6 +34,7 @@ public class AsyncConfigurerSupport implements AsyncConfigurer { @Override + @Nullable public Executor getAsyncExecutor() { return null; } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java index c814b7382128..0048321d2aac 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java @@ -334,16 +334,19 @@ public LastExecutionAdapter(@Nullable LastExecution le) { } @Override + @Nullable public Instant lastScheduledExecution() { return (this.le != null ? toInstant(this.le.getScheduledStart()) : null); } @Override + @Nullable public Instant lastActualExecution() { return (this.le != null ? toInstant(this.le.getRunStart()) : null); } @Override + @Nullable public Instant lastCompletion() { return (this.le != null ? toInstant(this.le.getRunEnd()) : null); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/TaskSchedulerRouter.java b/spring-context/src/main/java/org/springframework/scheduling/config/TaskSchedulerRouter.java index 480bbca6fe7f..21898b50efa2 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/TaskSchedulerRouter.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/TaskSchedulerRouter.java @@ -106,6 +106,7 @@ public void setBeanFactory(@Nullable BeanFactory beanFactory) { @Override + @Nullable public ScheduledFuture schedule(Runnable task, Trigger trigger) { return determineTargetScheduler(task).schedule(task, trigger); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java b/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java index 80778a19166c..dc8c9a4ab527 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java @@ -112,6 +112,7 @@ public String getExpression() { * previous execution; therefore, overlapping executions won't occur. */ @Override + @Nullable public Instant nextExecution(TriggerContext triggerContext) { Instant timestamp = determineLatestTimestamp(triggerContext); ZoneId zone = (this.zoneId != null ? this.zoneId : triggerContext.getClock().getZone()); diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/QuartzCronField.java b/spring-context/src/main/java/org/springframework/scheduling/support/QuartzCronField.java index 288957a99a48..8c0873d15109 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/QuartzCronField.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/QuartzCronField.java @@ -338,6 +338,7 @@ private static Temporal rollbackToMidnight(Temporal current, Temporal result) { @Override + @Nullable public > T nextOrSame(T temporal) { T result = adjust(temporal); if (result != null) { diff --git a/spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java b/spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java index ba2e2c4e906d..f4068e09cbb0 100644 --- a/spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java +++ b/spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; /** @@ -38,6 +39,7 @@ class ScriptingDefaultsParser implements BeanDefinitionParser { @Override + @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinition bd = LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry()); diff --git a/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java b/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java index e181bc00205a..6d8b6c5e2e09 100644 --- a/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java @@ -305,6 +305,7 @@ public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, Str } @Override + @Nullable public Object postProcessBeforeInstantiation(Class beanClass, String beanName) { // We only apply special treatment to ScriptFactory implementations here. if (!ScriptFactory.class.isAssignableFrom(beanClass)) { diff --git a/spring-context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java b/spring-context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java index 15ef3ae4667f..61675d953e17 100644 --- a/spring-context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java +++ b/spring-context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java @@ -70,6 +70,7 @@ public void initConversion(ConversionService conversionService) { * @see #getPropertyAccessor() */ @Override + @Nullable public PropertyEditorRegistry getPropertyEditorRegistry() { return (getTarget() != null ? getPropertyAccessor() : null); } @@ -109,6 +110,7 @@ protected Object getActualFieldValue(String field) { * @see #getCustomEditor */ @Override + @Nullable protected Object formatFieldValue(String field, @Nullable Object value) { String fixedField = fixedField(field); // Try custom editor... diff --git a/spring-context/src/main/java/org/springframework/validation/SimpleErrors.java b/spring-context/src/main/java/org/springframework/validation/SimpleErrors.java index 21c616ffdd99..6854f26235ea 100644 --- a/spring-context/src/main/java/org/springframework/validation/SimpleErrors.java +++ b/spring-context/src/main/java/org/springframework/validation/SimpleErrors.java @@ -147,6 +147,7 @@ public Object getFieldValue(String field) { } @Override + @Nullable public Class getFieldType(String field) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(this.target.getClass(), field); if (pd != null) { diff --git a/spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java b/spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java index 3fc328146f70..aa76afd0c2b1 100644 --- a/spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java +++ b/spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java @@ -147,6 +147,7 @@ public List getGlobalErrors() { } @Override + @Nullable public ObjectError getGlobalError() { return this.errors.getGlobalError(); } @@ -167,6 +168,7 @@ public List getFieldErrors() { } @Override + @Nullable public FieldError getFieldError() { return this.errors.getFieldError(); } @@ -187,16 +189,19 @@ public List getFieldErrors(String field) { } @Override + @Nullable public FieldError getFieldError(String field) { return this.errors.getFieldError(field); } @Override + @Nullable public Object getFieldValue(String field) { return this.errors.getFieldError(field); } @Override + @Nullable public Class getFieldType(String field) { return this.errors.getFieldType(field); } diff --git a/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java b/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java index d4951f15141f..f31cb20df6d1 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java @@ -62,7 +62,7 @@ public class BindingReflectionHintsRegistrar { * @param hints the hints instance to use * @param types the types to register */ - public void registerReflectionHints(ReflectionHints hints, Type... types) { + public void registerReflectionHints(ReflectionHints hints, @Nullable Type... types) { Set seen = new LinkedHashSet<>(); for (Type type : types) { registerReflectionHints(hints, seen, type); diff --git a/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java b/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java index 8ad247f15c38..cf5781a60e0b 100644 --- a/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java +++ b/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java @@ -92,7 +92,7 @@ public static Deferred monoToDeferred(Mono source) { * @return the method invocation result as reactive stream * @throws IllegalArgumentException if {@code method} is not a suspending function */ - public static Publisher invokeSuspendingFunction(Method method, Object target, Object... args) { + public static Publisher invokeSuspendingFunction(Method method, Object target, @Nullable Object... args) { return invokeSuspendingFunction(Dispatchers.getUnconfined(), method, target, args); } @@ -110,7 +110,7 @@ public static Publisher invokeSuspendingFunction(Method method, Object target */ @SuppressWarnings({"deprecation", "DataFlowIssue"}) public static Publisher invokeSuspendingFunction( - CoroutineContext context, Method method, @Nullable Object target, Object... args) { + CoroutineContext context, Method method, @Nullable Object target, @Nullable Object... args) { Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "Method must be a suspending function"); KFunction function = ReflectJvmMapping.getKotlinFunction(method); diff --git a/spring-core/src/main/java/org/springframework/core/NestedRuntimeException.java b/spring-core/src/main/java/org/springframework/core/NestedRuntimeException.java index ab0eefb213a8..bd6afe4d14cc 100644 --- a/spring-core/src/main/java/org/springframework/core/NestedRuntimeException.java +++ b/spring-core/src/main/java/org/springframework/core/NestedRuntimeException.java @@ -41,7 +41,7 @@ public abstract class NestedRuntimeException extends RuntimeException { * Construct a {@code NestedRuntimeException} with the specified detail message. * @param msg the detail message */ - public NestedRuntimeException(String msg) { + public NestedRuntimeException(@Nullable String msg) { super(msg); } diff --git a/spring-core/src/main/java/org/springframework/core/codec/CodecException.java b/spring-core/src/main/java/org/springframework/core/codec/CodecException.java index 0cdd1de57dc2..f621858783a7 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/CodecException.java +++ b/spring-core/src/main/java/org/springframework/core/codec/CodecException.java @@ -34,7 +34,7 @@ public class CodecException extends NestedRuntimeException { * Create a new CodecException. * @param msg the detail message */ - public CodecException(String msg) { + public CodecException(@Nullable String msg) { super(msg); } @@ -43,7 +43,7 @@ public CodecException(String msg) { * @param msg the detail message * @param cause root cause for the exception, if any */ - public CodecException(String msg, @Nullable Throwable cause) { + public CodecException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-core/src/main/java/org/springframework/core/codec/DecodingException.java b/spring-core/src/main/java/org/springframework/core/codec/DecodingException.java index c825f08e8a38..873996dbcb36 100644 --- a/spring-core/src/main/java/org/springframework/core/codec/DecodingException.java +++ b/spring-core/src/main/java/org/springframework/core/codec/DecodingException.java @@ -39,7 +39,7 @@ public class DecodingException extends CodecException { * Create a new DecodingException. * @param msg the detail message */ - public DecodingException(String msg) { + public DecodingException(@Nullable String msg) { super(msg); } @@ -48,7 +48,7 @@ public DecodingException(String msg) { * @param msg the detail message * @param cause root cause for the exception, if any */ - public DecodingException(String msg, @Nullable Throwable cause) { + public DecodingException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-core/src/main/java/org/springframework/util/StreamUtils.java b/spring-core/src/main/java/org/springframework/util/StreamUtils.java index 9d982f89a6f9..c9d7035a9d21 100644 --- a/spring-core/src/main/java/org/springframework/util/StreamUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StreamUtils.java @@ -201,7 +201,7 @@ else if (bytesRead <= bytesToCopy) { * @throws IOException in case of I/O errors * @since 4.3 */ - public static int drain(InputStream in) throws IOException { + public static int drain(@Nullable InputStream in) throws IOException { Assert.notNull(in, "No InputStream specified"); return (int) in.transferTo(OutputStream.nullOutputStream()); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryRuntimeHints.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryRuntimeHints.java index f39c3cc0e2b5..f78c97c746ab 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryRuntimeHints.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryRuntimeHints.java @@ -21,6 +21,7 @@ import org.springframework.aot.hint.ExecutableMode; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.lang.Nullable; /** * {@link RuntimeHintsRegistrar} implementation that registers reflection hints for @@ -33,7 +34,7 @@ class EmbeddedDatabaseFactoryRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { hints.reflection().registerTypeIfPresent(classLoader, "org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory$EmbeddedDataSourceProxy", builder -> builder 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 4598ddf9af28..0799a5033ee1 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(@Nullable String msg, Throwable cause) { + public ObjectOptimisticLockingFailureException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); this.persistentClass = null; this.identifier = null; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerRuntimeHints.java b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerRuntimeHints.java index eb6e204028d2..ad68ac63f9b6 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerRuntimeHints.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerRuntimeHints.java @@ -22,6 +22,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -42,7 +43,7 @@ class EntityManagerRuntimeHints implements RuntimeHintsRegistrar { private static final String NATIVE_QUERY_IMPL_CLASS_NAME = "org.hibernate.query.sql.internal.NativeQueryImpl"; @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { if (ClassUtils.isPresent(HIBERNATE_SESSION_FACTORY_CLASS_NAME, classLoader)) { hints.proxies().registerJdkProxy(TypeReference.of(HIBERNATE_SESSION_FACTORY_CLASS_NAME), TypeReference.of(EntityManagerFactoryInfo.class)); diff --git a/spring-tx/src/main/java/org/springframework/dao/CannotAcquireLockException.java b/spring-tx/src/main/java/org/springframework/dao/CannotAcquireLockException.java index 5a36c2381545..c385798a0ff9 100644 --- a/spring-tx/src/main/java/org/springframework/dao/CannotAcquireLockException.java +++ b/spring-tx/src/main/java/org/springframework/dao/CannotAcquireLockException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception thrown on failure to acquire a lock during an update, * for example during a "select for update" statement. @@ -32,7 +34,7 @@ public class CannotAcquireLockException extends PessimisticLockingFailureExcepti * Constructor for CannotAcquireLockException. * @param msg the detail message */ - public CannotAcquireLockException(String msg) { + public CannotAcquireLockException(@Nullable String msg) { super(msg); } @@ -41,7 +43,7 @@ public CannotAcquireLockException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public CannotAcquireLockException(String msg, Throwable cause) { + public CannotAcquireLockException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/ConcurrencyFailureException.java b/spring-tx/src/main/java/org/springframework/dao/ConcurrencyFailureException.java index 4f1031ce3f14..5487ffa670dd 100644 --- a/spring-tx/src/main/java/org/springframework/dao/ConcurrencyFailureException.java +++ b/spring-tx/src/main/java/org/springframework/dao/ConcurrencyFailureException.java @@ -36,7 +36,7 @@ public class ConcurrencyFailureException extends TransientDataAccessException { * Constructor for ConcurrencyFailureException. * @param msg the detail message */ - public ConcurrencyFailureException(String msg) { + public ConcurrencyFailureException(@Nullable String msg) { super(msg); } @@ -45,7 +45,7 @@ public ConcurrencyFailureException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public ConcurrencyFailureException(String msg, @Nullable Throwable cause) { + public ConcurrencyFailureException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/DataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/DataAccessException.java index 19098424c095..32479d9c02d4 100644 --- a/spring-tx/src/main/java/org/springframework/dao/DataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/DataAccessException.java @@ -43,7 +43,7 @@ public abstract class DataAccessException extends NestedRuntimeException { * Constructor for DataAccessException. * @param msg the detail message */ - public DataAccessException(String msg) { + public DataAccessException(@Nullable String msg) { super(msg); } diff --git a/spring-tx/src/main/java/org/springframework/dao/DataAccessResourceFailureException.java b/spring-tx/src/main/java/org/springframework/dao/DataAccessResourceFailureException.java index f3cd851aaa1d..d4847037856f 100644 --- a/spring-tx/src/main/java/org/springframework/dao/DataAccessResourceFailureException.java +++ b/spring-tx/src/main/java/org/springframework/dao/DataAccessResourceFailureException.java @@ -32,7 +32,7 @@ public class DataAccessResourceFailureException extends NonTransientDataAccessRe * Constructor for DataAccessResourceFailureException. * @param msg the detail message */ - public DataAccessResourceFailureException(String msg) { + public DataAccessResourceFailureException(@Nullable String msg) { super(msg); } @@ -41,7 +41,7 @@ public DataAccessResourceFailureException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public DataAccessResourceFailureException(String msg, @Nullable Throwable cause) { + public DataAccessResourceFailureException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/DataIntegrityViolationException.java b/spring-tx/src/main/java/org/springframework/dao/DataIntegrityViolationException.java index 0e561e04e238..21e36f4720cc 100644 --- a/spring-tx/src/main/java/org/springframework/dao/DataIntegrityViolationException.java +++ b/spring-tx/src/main/java/org/springframework/dao/DataIntegrityViolationException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception thrown when an attempt to insert or update data * results in violation of an integrity constraint. Note that this @@ -36,7 +38,7 @@ public class DataIntegrityViolationException extends NonTransientDataAccessExcep * Constructor for DataIntegrityViolationException. * @param msg the detail message */ - public DataIntegrityViolationException(String msg) { + public DataIntegrityViolationException(@Nullable String msg) { super(msg); } @@ -45,7 +47,7 @@ public DataIntegrityViolationException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public DataIntegrityViolationException(String msg, Throwable cause) { + public DataIntegrityViolationException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/DataRetrievalFailureException.java b/spring-tx/src/main/java/org/springframework/dao/DataRetrievalFailureException.java index 0ab0c91aafcf..6b36a34ab566 100644 --- a/spring-tx/src/main/java/org/springframework/dao/DataRetrievalFailureException.java +++ b/spring-tx/src/main/java/org/springframework/dao/DataRetrievalFailureException.java @@ -33,7 +33,7 @@ public class DataRetrievalFailureException extends NonTransientDataAccessExcepti * Constructor for DataRetrievalFailureException. * @param msg the detail message */ - public DataRetrievalFailureException(String msg) { + public DataRetrievalFailureException(@Nullable String msg) { super(msg); } @@ -42,7 +42,7 @@ public DataRetrievalFailureException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public DataRetrievalFailureException(String msg, @Nullable Throwable cause) { + public DataRetrievalFailureException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/DuplicateKeyException.java b/spring-tx/src/main/java/org/springframework/dao/DuplicateKeyException.java index 36ee084c9e7b..06051f6e6e77 100644 --- a/spring-tx/src/main/java/org/springframework/dao/DuplicateKeyException.java +++ b/spring-tx/src/main/java/org/springframework/dao/DuplicateKeyException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception thrown when an attempt to insert or update data * results in violation of a primary key or unique constraint. @@ -34,7 +36,7 @@ public class DuplicateKeyException extends DataIntegrityViolationException { * Constructor for DuplicateKeyException. * @param msg the detail message */ - public DuplicateKeyException(String msg) { + public DuplicateKeyException(@Nullable String msg) { super(msg); } @@ -43,7 +45,7 @@ public DuplicateKeyException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public DuplicateKeyException(String msg, Throwable cause) { + public DuplicateKeyException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java index 535870a423ef..f3308118b74b 100644 --- a/spring-tx/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/EmptyResultDataAccessException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Data access exception thrown when a result was expected to have at least * one row (or element) but zero rows (or elements) were actually returned. @@ -40,7 +42,7 @@ public EmptyResultDataAccessException(int expectedSize) { * @param msg the detail message * @param expectedSize the expected result size */ - public EmptyResultDataAccessException(String msg, int expectedSize) { + public EmptyResultDataAccessException(@Nullable String msg, int expectedSize) { super(msg, expectedSize, 0); } @@ -50,7 +52,7 @@ public EmptyResultDataAccessException(String msg, int expectedSize) { * @param expectedSize the expected result size * @param ex the wrapped exception */ - public EmptyResultDataAccessException(String msg, int expectedSize, Throwable ex) { + public EmptyResultDataAccessException(@Nullable String msg, int expectedSize, Throwable ex) { super(msg, expectedSize, 0, ex); } diff --git a/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java index d0fdb2a542a7..66b5d79a230f 100644 --- a/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/IncorrectResultSizeDataAccessException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Data access exception thrown when a result was not of the expected size, * for example when expecting a single row but getting 0 or more than 1 rows. @@ -71,7 +73,7 @@ public IncorrectResultSizeDataAccessException(String msg, int expectedSize) { * @param expectedSize the expected result size * @param ex the wrapped exception */ - public IncorrectResultSizeDataAccessException(String msg, int expectedSize, Throwable ex) { + public IncorrectResultSizeDataAccessException(@Nullable String msg, int expectedSize, @Nullable Throwable ex) { super(msg, ex); this.expectedSize = expectedSize; this.actualSize = -1; @@ -83,7 +85,7 @@ public IncorrectResultSizeDataAccessException(String msg, int expectedSize, Thro * @param expectedSize the expected result size * @param actualSize the actual result size (or -1 if unknown) */ - public IncorrectResultSizeDataAccessException(String msg, int expectedSize, int actualSize) { + public IncorrectResultSizeDataAccessException(@Nullable String msg, int expectedSize, int actualSize) { super(msg); this.expectedSize = expectedSize; this.actualSize = actualSize; @@ -96,7 +98,7 @@ public IncorrectResultSizeDataAccessException(String msg, int expectedSize, int * @param actualSize the actual result size (or -1 if unknown) * @param ex the wrapped exception */ - public IncorrectResultSizeDataAccessException(String msg, int expectedSize, int actualSize, Throwable ex) { + public IncorrectResultSizeDataAccessException(@Nullable String msg, int expectedSize, int actualSize, @Nullable Throwable ex) { super(msg, ex); this.expectedSize = expectedSize; this.actualSize = actualSize; diff --git a/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessApiUsageException.java b/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessApiUsageException.java index 54daec40dcf7..dbf1b536ddb1 100644 --- a/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessApiUsageException.java +++ b/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessApiUsageException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception thrown on incorrect usage of the API, such as failing to * "compile" a query object that needed compilation before execution. @@ -32,7 +34,7 @@ public class InvalidDataAccessApiUsageException extends NonTransientDataAccessEx * Constructor for InvalidDataAccessApiUsageException. * @param msg the detail message */ - public InvalidDataAccessApiUsageException(String msg) { + public InvalidDataAccessApiUsageException(@Nullable String msg) { super(msg); } @@ -41,7 +43,7 @@ public InvalidDataAccessApiUsageException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public InvalidDataAccessApiUsageException(String msg, Throwable cause) { + public InvalidDataAccessApiUsageException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessResourceUsageException.java b/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessResourceUsageException.java index 218da9e056b6..e13fc2db7bb9 100644 --- a/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessResourceUsageException.java +++ b/spring-tx/src/main/java/org/springframework/dao/InvalidDataAccessResourceUsageException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Root for exceptions thrown when we use a data access resource incorrectly. * Thrown for example on specifying bad SQL when using a RDBMS. @@ -30,7 +32,7 @@ public class InvalidDataAccessResourceUsageException extends NonTransientDataAcc * Constructor for InvalidDataAccessResourceUsageException. * @param msg the detail message */ - public InvalidDataAccessResourceUsageException(String msg) { + public InvalidDataAccessResourceUsageException(@Nullable String msg) { super(msg); } @@ -39,7 +41,7 @@ public InvalidDataAccessResourceUsageException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public InvalidDataAccessResourceUsageException(String msg, Throwable cause) { + public InvalidDataAccessResourceUsageException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessException.java index 4fb6b7498a43..7620c039f20f 100644 --- a/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessException.java @@ -34,7 +34,7 @@ public abstract class NonTransientDataAccessException extends DataAccessExceptio * Constructor for NonTransientDataAccessException. * @param msg the detail message */ - public NonTransientDataAccessException(String msg) { + public NonTransientDataAccessException(@Nullable String msg) { super(msg); } diff --git a/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessResourceException.java b/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessResourceException.java index 78094e6ce9b2..5d8a8ebfbfac 100644 --- a/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessResourceException.java +++ b/spring-tx/src/main/java/org/springframework/dao/NonTransientDataAccessResourceException.java @@ -32,7 +32,7 @@ public class NonTransientDataAccessResourceException extends NonTransientDataAcc * Constructor for NonTransientDataAccessResourceException. * @param msg the detail message */ - public NonTransientDataAccessResourceException(String msg) { + public NonTransientDataAccessResourceException(@Nullable String msg) { super(msg); } @@ -41,7 +41,7 @@ public NonTransientDataAccessResourceException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public NonTransientDataAccessResourceException(String msg, @Nullable Throwable cause) { + public NonTransientDataAccessResourceException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/OptimisticLockingFailureException.java b/spring-tx/src/main/java/org/springframework/dao/OptimisticLockingFailureException.java index c1c8189d7ab8..09f16de1d7f6 100644 --- a/spring-tx/src/main/java/org/springframework/dao/OptimisticLockingFailureException.java +++ b/spring-tx/src/main/java/org/springframework/dao/OptimisticLockingFailureException.java @@ -35,7 +35,7 @@ public class OptimisticLockingFailureException extends ConcurrencyFailureExcepti * Constructor for OptimisticLockingFailureException. * @param msg the detail message */ - public OptimisticLockingFailureException(String msg) { + public OptimisticLockingFailureException(@Nullable String msg) { super(msg); } @@ -44,7 +44,7 @@ public OptimisticLockingFailureException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public OptimisticLockingFailureException(String msg, @Nullable Throwable cause) { + public OptimisticLockingFailureException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/PessimisticLockingFailureException.java b/spring-tx/src/main/java/org/springframework/dao/PessimisticLockingFailureException.java index 31599203a997..b0b5547679b2 100644 --- a/spring-tx/src/main/java/org/springframework/dao/PessimisticLockingFailureException.java +++ b/spring-tx/src/main/java/org/springframework/dao/PessimisticLockingFailureException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception thrown on a pessimistic locking violation. * Thrown by Spring's SQLException translation mechanism @@ -37,7 +39,7 @@ public class PessimisticLockingFailureException extends ConcurrencyFailureExcept * Constructor for PessimisticLockingFailureException. * @param msg the detail message */ - public PessimisticLockingFailureException(String msg) { + public PessimisticLockingFailureException(@Nullable String msg) { super(msg); } @@ -46,7 +48,7 @@ public PessimisticLockingFailureException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public PessimisticLockingFailureException(String msg, Throwable cause) { + public PessimisticLockingFailureException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/QueryTimeoutException.java b/spring-tx/src/main/java/org/springframework/dao/QueryTimeoutException.java index 31dccdab2065..6787815eba27 100644 --- a/spring-tx/src/main/java/org/springframework/dao/QueryTimeoutException.java +++ b/spring-tx/src/main/java/org/springframework/dao/QueryTimeoutException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception to be thrown on a query timeout. This could have different causes depending on * the database API in use but most likely thrown after the database interrupts or stops @@ -34,7 +36,7 @@ public class QueryTimeoutException extends TransientDataAccessException { * Constructor for QueryTimeoutException. * @param msg the detail message */ - public QueryTimeoutException(String msg) { + public QueryTimeoutException(@Nullable String msg) { super(msg); } @@ -43,7 +45,7 @@ public QueryTimeoutException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public QueryTimeoutException(String msg, Throwable cause) { + public QueryTimeoutException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/TransientDataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/TransientDataAccessException.java index 98981e6dc9ff..761baabca126 100644 --- a/spring-tx/src/main/java/org/springframework/dao/TransientDataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/TransientDataAccessException.java @@ -34,7 +34,7 @@ public abstract class TransientDataAccessException extends DataAccessException { * Constructor for TransientDataAccessException. * @param msg the detail message */ - public TransientDataAccessException(String msg) { + public TransientDataAccessException(@Nullable String msg) { super(msg); } @@ -44,7 +44,7 @@ public TransientDataAccessException(String msg) { * @param cause the root cause (usually from using an underlying * data access API such as JDBC) */ - public TransientDataAccessException(String msg, @Nullable Throwable cause) { + public TransientDataAccessException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/dao/TypeMismatchDataAccessException.java b/spring-tx/src/main/java/org/springframework/dao/TypeMismatchDataAccessException.java index 2808cfe04efa..ac8c75651f28 100644 --- a/spring-tx/src/main/java/org/springframework/dao/TypeMismatchDataAccessException.java +++ b/spring-tx/src/main/java/org/springframework/dao/TypeMismatchDataAccessException.java @@ -16,6 +16,8 @@ package org.springframework.dao; +import org.springframework.lang.Nullable; + /** * Exception thrown on mismatch between Java type and database type: * for example on an attempt to set an object of the wrong type @@ -30,7 +32,7 @@ public class TypeMismatchDataAccessException extends InvalidDataAccessResourceUs * Constructor for TypeMismatchDataAccessException. * @param msg the detail message */ - public TypeMismatchDataAccessException(String msg) { + public TypeMismatchDataAccessException(@Nullable String msg) { super(msg); } @@ -39,7 +41,7 @@ public TypeMismatchDataAccessException(String msg) { * @param msg the detail message * @param cause the root cause from the data access API in use */ - public TypeMismatchDataAccessException(String msg, Throwable cause) { + public TypeMismatchDataAccessException(@Nullable String msg, @Nullable Throwable cause) { super(msg, cause); } diff --git a/spring-tx/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java b/spring-tx/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java index 2a514d2a32f3..3c4d213367ed 100644 --- a/spring-tx/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java +++ b/spring-tx/src/main/java/org/springframework/jca/support/LocalConnectionFactoryBean.java @@ -132,6 +132,7 @@ public Object getObject() { } @Override + @Nullable public Class getObjectType() { return (this.connectionFactory != null ? this.connectionFactory.getClass() : null); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionBeanRegistrationAotProcessor.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionBeanRegistrationAotProcessor.java index 046937012090..e8abaa78ebfb 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionBeanRegistrationAotProcessor.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionBeanRegistrationAotProcessor.java @@ -28,6 +28,7 @@ import org.springframework.beans.factory.aot.BeanRegistrationCode; import org.springframework.beans.factory.support.RegisteredBean; import org.springframework.core.annotation.MergedAnnotations; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; @@ -46,6 +47,7 @@ class TransactionBeanRegistrationAotProcessor implements BeanRegistrationAotProc @Override + @Nullable public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) { Class beanClass = registeredBean.getBeanClass(); if (isTransactional(beanClass)) { diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionRuntimeHints.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionRuntimeHints.java index 975d93be0a49..60dc32eb734d 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionRuntimeHints.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionRuntimeHints.java @@ -21,6 +21,7 @@ import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeHint; import org.springframework.aot.hint.TypeReference; +import org.springframework.lang.Nullable; /** * {@link RuntimeHintsRegistrar} implementation that registers runtime hints for @@ -33,7 +34,7 @@ class TransactionRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { hints.reflection().registerTypes(TypeReference.listOf(Isolation.class, Propagation.class), TypeHint.builtWith(MemberCategory.DECLARED_FIELDS)); } diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index 97f7735d3391..7697538739d3 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -788,19 +788,19 @@ public BuilderImpl(String type) { } @Override - public Builder name(String name) { + public Builder name(@Nullable String name) { this.name = name; return this; } @Override - public Builder filename(String filename) { + public Builder filename(@Nullable String filename) { this.filename = filename; return this; } @Override - public Builder filename(String filename, Charset charset) { + public Builder filename(@Nullable String filename, @Nullable Charset charset) { this.filename = filename; this.charset = charset; return this; @@ -808,28 +808,28 @@ public Builder filename(String filename, Charset charset) { @Override @SuppressWarnings("deprecation") - public Builder size(Long size) { + public Builder size(@Nullable Long size) { this.size = size; return this; } @Override @SuppressWarnings("deprecation") - public Builder creationDate(ZonedDateTime creationDate) { + public Builder creationDate(@Nullable ZonedDateTime creationDate) { this.creationDate = creationDate; return this; } @Override @SuppressWarnings("deprecation") - public Builder modificationDate(ZonedDateTime modificationDate) { + public Builder modificationDate(@Nullable ZonedDateTime modificationDate) { this.modificationDate = modificationDate; return this; } @Override @SuppressWarnings("deprecation") - public Builder readDate(ZonedDateTime readDate) { + public Builder readDate(@Nullable ZonedDateTime readDate) { this.readDate = readDate; return this; } diff --git a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java index 4df2316b62ce..2ab996f9adee 100644 --- a/spring-web/src/main/java/org/springframework/http/ProblemDetail.java +++ b/spring-web/src/main/java/org/springframework/http/ProblemDetail.java @@ -301,7 +301,7 @@ public static ProblemDetail forStatus(int status) { /** * Create a {@code ProblemDetail} instance with the given status and detail. */ - public static ProblemDetail forStatusAndDetail(HttpStatusCode status, String detail) { + public static ProblemDetail forStatusAndDetail(HttpStatusCode status, @Nullable String detail) { Assert.notNull(status, "HttpStatusCode is required"); ProblemDetail problemDetail = forStatus(status.value()); problemDetail.setDetail(detail); diff --git a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java index 7c16b19d6799..0298fa2dff3d 100644 --- a/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/ReadOnlyHttpHeaders.java @@ -54,6 +54,7 @@ class ReadOnlyHttpHeaders extends HttpHeaders { @Override + @Nullable public MediaType getContentType() { if (this.cachedContentType != null) { return this.cachedContentType; @@ -83,6 +84,7 @@ public void clearContentHeaders() { } @Override + @Nullable public List get(Object key) { List values = this.headers.get(key); return (values != null ? Collections.unmodifiableList(values) : null); diff --git a/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborDecoder.java index 35bb39f09336..7d04e82c14de 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborDecoder.java @@ -28,6 +28,7 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.json.AbstractJackson2Decoder; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -53,7 +54,7 @@ public Jackson2CborDecoder(ObjectMapper mapper, MimeType... mimeTypes) { @Override - public Flux decode(Publisher input, ResolvableType elementType, MimeType mimeType, Map hints) { + public Flux decode(Publisher input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map hints) { throw new UnsupportedOperationException("Does not support stream decoding yet"); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborEncoder.java b/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborEncoder.java index 424e3ec4b681..bee3462e736c 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborEncoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborEncoder.java @@ -29,6 +29,7 @@ import org.springframework.http.MediaType; import org.springframework.http.codec.json.AbstractJackson2Encoder; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.MimeType; @@ -54,7 +55,8 @@ public Jackson2CborEncoder(ObjectMapper mapper, MimeType... mimeTypes) { @Override - public Flux encode(Publisher inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map hints) { + public Flux encode(Publisher inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, + @Nullable MimeType mimeType, @Nullable Map hints) { throw new UnsupportedOperationException("Does not support stream encoding yet"); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java index eefdb10a3479..2cf3fc8b7f9a 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java @@ -300,6 +300,7 @@ public List getDecodableMimeTypes(ResolvableType targetType) { // Jackson2CodecSupport @Override + @Nullable protected A getAnnotation(MethodParameter parameter, Class annotType) { return parameter.getParameterAnnotation(annotType); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java index c8dd9c4c08cb..78e20160efe2 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Encoder.java @@ -426,6 +426,7 @@ public Map getEncodeHints(@Nullable ResolvableType actualType, R // Jackson2CodecSupport @Override + @Nullable protected A getAnnotation(MethodParameter parameter, Class annotType) { return parameter.getMethodAnnotation(annotType); } diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java index 54c09b882312..90c89b7239bb 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java @@ -82,6 +82,7 @@ protected Resource readInternal(Class clazz, HttpInputMessag if (this.supportsReadStreaming && InputStreamResource.class == clazz) { return new InputStreamResource(inputMessage.getBody()) { @Override + @Nullable public String getFilename() { return inputMessage.getHeaders().getContentDisposition().getFilename(); } diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java index a9f332645dee..83c1e5b22379 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java @@ -469,6 +469,7 @@ public ObjectMapper getObject() { } @Override + @Nullable public Class getObjectType() { return (this.objectMapper != null ? this.objectMapper.getClass() : null); } diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/JacksonModulesRuntimeHints.java b/spring-web/src/main/java/org/springframework/http/converter/json/JacksonModulesRuntimeHints.java index b6619f1f20d7..2c41e5165bd5 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/JacksonModulesRuntimeHints.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/JacksonModulesRuntimeHints.java @@ -22,6 +22,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeHint.Builder; +import org.springframework.lang.Nullable; /** * {@link RuntimeHintsRegistrar} implementation that registers reflection entries @@ -38,7 +39,7 @@ class JacksonModulesRuntimeHints implements RuntimeHintsRegistrar { .withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { hints.reflection() .registerTypeIfPresent(classLoader, "com.fasterxml.jackson.datatype.jdk8.Jdk8Module", asJacksonModule) diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailRuntimeHints.java b/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailRuntimeHints.java index 3f569c44d3e7..8d4ef0a39aa2 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailRuntimeHints.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/ProblemDetailRuntimeHints.java @@ -20,6 +20,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.http.ProblemDetail; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -33,7 +34,7 @@ class ProblemDetailRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar(); bindingRegistrar.registerReflectionHints(hints.reflection(), ProblemDetail.class); if (ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", classLoader)) { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java index e336284d38fd..d6f7f85b953c 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpResponseDecorator.java @@ -61,6 +61,7 @@ public boolean setStatusCode(@Nullable HttpStatusCode status) { } @Override + @Nullable public HttpStatusCode getStatusCode() { return getDelegate().getStatusCode(); } @@ -71,6 +72,7 @@ public boolean setRawStatusCode(@Nullable Integer value) { } @Override + @Nullable @Deprecated public Integer getRawStatusCode() { return getDelegate().getRawStatusCode(); diff --git a/spring-web/src/main/java/org/springframework/web/client/support/RestTemplateAdapter.java b/spring-web/src/main/java/org/springframework/web/client/support/RestTemplateAdapter.java index 3cd2b927dbc1..364caa6be326 100644 --- a/spring-web/src/main/java/org/springframework/web/client/support/RestTemplateAdapter.java +++ b/spring-web/src/main/java/org/springframework/web/client/support/RestTemplateAdapter.java @@ -26,6 +26,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.web.client.RestTemplate; import org.springframework.web.service.invoker.HttpExchangeAdapter; @@ -70,6 +71,7 @@ public HttpHeaders exchangeForHeaders(HttpRequestValues values) { } @Override + @Nullable public T exchangeForBody(HttpRequestValues values, ParameterizedTypeReference bodyType) { return this.restTemplate.exchange(newRequest(values), bodyType).getBody(); } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java index a1a9e2737177..0c3d92fb7dd9 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java @@ -144,6 +144,7 @@ public String getNamespace() { } @Override + @Nullable public String[] getConfigLocations() { return super.getConfigLocations(); } diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java index a331034bf10f..a7ba4dff74e7 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java @@ -84,6 +84,7 @@ public Iterator getFileNames() { } @Override + @Nullable public MultipartFile getFile(String name) { return getMultipartFiles().getFirst(name); } diff --git a/spring-web/src/main/java/org/springframework/web/util/BindErrorUtils.java b/spring-web/src/main/java/org/springframework/web/util/BindErrorUtils.java index fbb951f6edd5..9230d0fb0daa 100644 --- a/spring-web/src/main/java/org/springframework/web/util/BindErrorUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/BindErrorUtils.java @@ -25,6 +25,7 @@ import org.springframework.context.MessageSource; import org.springframework.context.MessageSourceResolvable; import org.springframework.context.support.StaticMessageSource; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; import org.springframework.validation.FieldError; @@ -114,6 +115,7 @@ private static class MethodArgumentErrorMessageSource extends StaticMessageSourc } @Override + @Nullable protected String getDefaultMessage(MessageSourceResolvable resolvable, Locale locale) { String message = super.getDefaultMessage(resolvable, locale); return (resolvable instanceof FieldError error ? error.getField() + ": " + message : message); diff --git a/spring-web/src/main/java/org/springframework/web/util/WebUtilRuntimeHints.java b/spring-web/src/main/java/org/springframework/web/util/WebUtilRuntimeHints.java index 06976e58cdbc..6c9213ae0450 100644 --- a/spring-web/src/main/java/org/springframework/web/util/WebUtilRuntimeHints.java +++ b/spring-web/src/main/java/org/springframework/web/util/WebUtilRuntimeHints.java @@ -19,6 +19,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.core.io.ClassPathResource; +import org.springframework.lang.Nullable; /** * {@link RuntimeHintsRegistrar} implementation that registers resource @@ -30,7 +31,7 @@ class WebUtilRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { hints.resources().registerResource( new ClassPathResource("HtmlCharacterEntityReferences.properties", getClass())); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java index f115fc95d8df..c2ba3a9ff595 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequest.java @@ -337,6 +337,7 @@ public Optional contentType() { } @Override + @Nullable public InetSocketAddress host() { return this.httpHeaders.getHost(); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java index 8837aea44115..3231b4a87ebc 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolver.java @@ -80,6 +80,7 @@ public boolean supportsParameter(MethodParameter parameter) { } @Override + @Nullable public Object resolveArgumentValue( MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceRuntimeHints.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceRuntimeHints.java index f10e55ce5e49..83d29fe105fa 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceRuntimeHints.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceRuntimeHints.java @@ -19,6 +19,7 @@ import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; +import org.springframework.lang.Nullable; /** * {@link RuntimeHintsRegistrar} implementation that registers reflection hints related to @@ -30,7 +31,7 @@ class HandshakeWebSocketServiceRuntimeHints implements RuntimeHintsRegistrar { @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { hints.reflection().registerType(HandshakeWebSocketService.initUpgradeStrategy().getClass(), MemberCategory.INVOKE_DECLARED_CONSTRUCTORS); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java index ed44e6b057b0..5737e6606080 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/DefaultServerRequest.java @@ -378,6 +378,7 @@ public Optional contentType() { } @Override + @Nullable public InetSocketAddress host() { return this.httpHeaders.getHost(); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java index 3bdc25ecb724..6998234705cf 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HandshakeHandlerRuntimeHints.java @@ -21,6 +21,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.TypeReference; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -61,7 +62,7 @@ class HandshakeHandlerRuntimeHints implements RuntimeHintsRegistrar { } @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { ReflectionHints reflectionHints = hints.reflection(); if (tomcatWsPresent) { registerType(reflectionHints, "org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy");