Switch to JSpecify annotations
This commit updates the whole Spring Framework codebase to use JSpecify annotations instead of Spring null-safety annotations with JSR 305 semantics. JSpecify provides signficant enhancements such as properly defined specifications, a canonical dependency with no split-package issue, better tooling, better Kotlin integration and the capability to specify generic type, array and varargs element null-safety. Generic type null-safety is not defined by this commit yet and will be specified later. A key difference is that Spring null-safety annotations, following JSR 305 semantics, apply to fields, parameters and return values, while JSpecify annotations apply to type usages. That's why this commit moves nullability annotations closer to the type for fields and return values. See gh-28797
This commit is contained in:
@@ -23,9 +23,9 @@ import java.util.function.Supplier;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.AsyncCache;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.support.AbstractValueAdaptingCache;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -50,8 +50,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
|
||||
private final com.github.benmanes.caffeine.cache.Cache<Object, Object> cache;
|
||||
|
||||
@Nullable
|
||||
private AsyncCache<Object, Object> asyncCache;
|
||||
private @Nullable AsyncCache<Object, Object> asyncCache;
|
||||
|
||||
|
||||
/**
|
||||
@@ -130,14 +129,12 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
public <T> @Nullable T get(Object key, Callable<T> valueLoader) {
|
||||
return (T) fromStoreValue(this.cache.get(key, new LoadFunction(valueLoader)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CompletableFuture<?> retrieve(Object key) {
|
||||
public @Nullable CompletableFuture<?> retrieve(Object key) {
|
||||
CompletableFuture<?> result = getAsyncCache().getIfPresent(key);
|
||||
if (result != null && isAllowNullValues()) {
|
||||
result = result.thenApply(this::toValueWrapper);
|
||||
@@ -159,8 +156,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object lookup(Object key) {
|
||||
protected @Nullable Object lookup(Object key) {
|
||||
if (this.cache instanceof LoadingCache<Object, Object> loadingCache) {
|
||||
return loadingCache.get(key);
|
||||
}
|
||||
@@ -173,8 +169,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
|
||||
public @Nullable ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
|
||||
PutIfAbsentFunction callable = new PutIfAbsentFunction(value);
|
||||
Object result = this.cache.get(key, callable);
|
||||
return (callable.called ? null : toValueWrapper(result));
|
||||
@@ -205,8 +200,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
|
||||
private class PutIfAbsentFunction implements Function<Object, Object> {
|
||||
|
||||
@Nullable
|
||||
private final Object value;
|
||||
private final @Nullable Object value;
|
||||
|
||||
boolean called;
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ import com.github.benmanes.caffeine.cache.AsyncCacheLoader;
|
||||
import com.github.benmanes.caffeine.cache.CacheLoader;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.CaffeineSpec;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -70,8 +70,7 @@ public class CaffeineCacheManager implements CacheManager {
|
||||
|
||||
private Caffeine<Object, Object> cacheBuilder = Caffeine.newBuilder();
|
||||
|
||||
@Nullable
|
||||
private AsyncCacheLoader<Object, Object> cacheLoader;
|
||||
private @Nullable AsyncCacheLoader<Object, Object> cacheLoader;
|
||||
|
||||
private boolean asyncCacheMode = false;
|
||||
|
||||
@@ -251,8 +250,7 @@ public class CaffeineCacheManager implements CacheManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Cache getCache(String name) {
|
||||
public @Nullable Cache getCache(String name) {
|
||||
Cache cache = this.cacheMap.get(name);
|
||||
if (cache == null && this.dynamic) {
|
||||
cache = this.cacheMap.computeIfAbsent(name, this::createCaffeineCache);
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* <a href="https://github.com/ben-manes/caffeine/">Caffeine</a> library,
|
||||
* allowing to set up Caffeine caches within Spring's cache abstraction.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.cache.caffeine;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -24,8 +24,9 @@ import javax.cache.processor.EntryProcessor;
|
||||
import javax.cache.processor.EntryProcessorException;
|
||||
import javax.cache.processor.MutableEntry;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.support.AbstractValueAdaptingCache;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -79,15 +80,13 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object lookup(Object key) {
|
||||
protected @Nullable Object lookup(Object key) {
|
||||
return this.cache.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
public <T> @Nullable T get(Object key, Callable<T> valueLoader) {
|
||||
try {
|
||||
return (T) this.cache.invoke(key, this.valueLoaderEntryProcessor, valueLoader);
|
||||
}
|
||||
@@ -102,8 +101,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
|
||||
public @Nullable ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
|
||||
Object previous = this.cache.invoke(key, PutIfAbsentEntryProcessor.INSTANCE, toStoreValue(value));
|
||||
return (previous != null ? toValueWrapper(previous) : null);
|
||||
}
|
||||
@@ -136,8 +134,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
||||
private static final PutIfAbsentEntryProcessor INSTANCE = new PutIfAbsentEntryProcessor();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
|
||||
public @Nullable Object process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
|
||||
Object existingValue = entry.getValue();
|
||||
if (existingValue == null) {
|
||||
entry.setValue(arguments[0]);
|
||||
@@ -161,9 +158,8 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
|
||||
public @Nullable Object process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException {
|
||||
Callable<Object> valueLoader = (Callable<Object>) arguments[0];
|
||||
if (entry.exists()) {
|
||||
return this.fromStoreValue.apply(entry.getValue());
|
||||
|
||||
@@ -22,9 +22,10 @@ import java.util.LinkedHashSet;
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.Caching;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -40,8 +41,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {
|
||||
|
||||
@Nullable
|
||||
private CacheManager cacheManager;
|
||||
private @Nullable CacheManager cacheManager;
|
||||
|
||||
private boolean allowNullValues = true;
|
||||
|
||||
@@ -75,8 +75,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
|
||||
/**
|
||||
* Return the backing JCache {@link CacheManager javax.cache.CacheManager}.
|
||||
*/
|
||||
@Nullable
|
||||
public CacheManager getCacheManager() {
|
||||
public @Nullable CacheManager getCacheManager() {
|
||||
return this.cacheManager;
|
||||
}
|
||||
|
||||
@@ -121,8 +120,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Cache getMissingCache(String name) {
|
||||
protected @Nullable Cache getMissingCache(String name) {
|
||||
CacheManager cacheManager = getCacheManager();
|
||||
Assert.state(cacheManager != null, "No CacheManager set");
|
||||
|
||||
|
||||
@@ -22,11 +22,12 @@ import java.util.Properties;
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.Caching;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} for a JCache {@link CacheManager javax.cache.CacheManager},
|
||||
@@ -43,17 +44,13 @@ import org.springframework.lang.Nullable;
|
||||
public class JCacheManagerFactoryBean
|
||||
implements FactoryBean<CacheManager>, BeanClassLoaderAware, InitializingBean, DisposableBean {
|
||||
|
||||
@Nullable
|
||||
private URI cacheManagerUri;
|
||||
private @Nullable URI cacheManagerUri;
|
||||
|
||||
@Nullable
|
||||
private Properties cacheManagerProperties;
|
||||
private @Nullable Properties cacheManagerProperties;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader;
|
||||
private @Nullable ClassLoader beanClassLoader;
|
||||
|
||||
@Nullable
|
||||
private CacheManager cacheManager;
|
||||
private @Nullable CacheManager cacheManager;
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,8 +83,7 @@ public class JCacheManagerFactoryBean
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CacheManager getObject() {
|
||||
public @Nullable CacheManager getObject() {
|
||||
return this.cacheManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.cache.jcache.config;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.cache.annotation.AbstractCachingConfiguration;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
@@ -26,7 +28,6 @@ import org.springframework.cache.jcache.interceptor.JCacheOperationSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Abstract JSR-107 specific {@code @Configuration} class providing common
|
||||
@@ -40,8 +41,7 @@ import org.springframework.lang.Nullable;
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public abstract class AbstractJCacheConfiguration extends AbstractCachingConfiguration {
|
||||
|
||||
@Nullable
|
||||
protected Supplier<CacheResolver> exceptionCacheResolver;
|
||||
protected @Nullable Supplier<CacheResolver> exceptionCacheResolver;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.cache.jcache.config;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.annotation.CachingConfigurer;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@link CachingConfigurer} for the JSR-107 implementation.
|
||||
@@ -57,8 +58,7 @@ public interface JCacheConfigurer extends CachingConfigurer {
|
||||
* </pre>
|
||||
* See {@link org.springframework.cache.annotation.EnableCaching} for more complete examples.
|
||||
*/
|
||||
@Nullable
|
||||
default CacheResolver exceptionCacheResolver() {
|
||||
default @Nullable CacheResolver exceptionCacheResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.cache.jcache.config;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* An extension of {@link CachingConfigurerSupport} that also implements
|
||||
@@ -37,8 +38,7 @@ import org.springframework.lang.Nullable;
|
||||
public class JCacheConfigurerSupport extends CachingConfigurerSupport implements JCacheConfigurer {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CacheResolver exceptionCacheResolver() {
|
||||
public @Nullable CacheResolver exceptionCacheResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
* <p>Provides an extension of the {@code CachingConfigurer} that exposes
|
||||
* the exception cache resolver to use (see {@code JCacheConfigurer}).
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.cache.jcache.config;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -22,13 +22,13 @@ import java.util.Collection;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.interceptor.AbstractCacheInvoker;
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvocationContext;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvoker;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -51,8 +51,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
protected abstract Object invoke(CacheOperationInvocationContext<O> context, CacheOperationInvoker invoker)
|
||||
protected abstract @Nullable Object invoke(CacheOperationInvocationContext<O> context, CacheOperationInvoker invoker)
|
||||
throws Throwable;
|
||||
|
||||
|
||||
@@ -75,8 +74,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
|
||||
* <p>Throw an {@link IllegalStateException} if the collection holds more than one element
|
||||
* @return the single element, or {@code null} if the collection is empty
|
||||
*/
|
||||
@Nullable
|
||||
static Cache extractFrom(Collection<? extends Cache> caches) {
|
||||
static @Nullable Cache extractFrom(Collection<? extends Cache> caches) {
|
||||
if (CollectionUtils.isEmpty(caches)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.core.MethodClassKey;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -59,13 +59,11 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass) {
|
||||
public @Nullable JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass) {
|
||||
return getCacheOperation(method, targetClass, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass, boolean cacheNull) {
|
||||
private @Nullable JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass, boolean cacheNull) {
|
||||
if (ReflectionUtils.isObjectMethod(method)) {
|
||||
return null;
|
||||
}
|
||||
@@ -91,8 +89,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JCacheOperation<?> computeCacheOperation(Method method, @Nullable Class<?> targetClass) {
|
||||
private @Nullable JCacheOperation<?> computeCacheOperation(Method method, @Nullable Class<?> targetClass) {
|
||||
// Don't allow non-public methods, as configured.
|
||||
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
|
||||
return null;
|
||||
@@ -126,8 +123,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
|
||||
* @return the cache operation associated with this method
|
||||
* (or {@code null} if none)
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType);
|
||||
protected abstract @Nullable JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType);
|
||||
|
||||
/**
|
||||
* Should only public methods be allowed to have caching semantics?
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.List;
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
|
||||
@@ -74,7 +76,7 @@ abstract class AbstractJCacheKeyOperation<A extends Annotation> extends Abstract
|
||||
* @return the {@link CacheInvocationParameter} instances for the parameters to be
|
||||
* used to compute the key
|
||||
*/
|
||||
public CacheInvocationParameter[] getKeyParameters(Object... values) {
|
||||
public CacheInvocationParameter[] getKeyParameters(@Nullable Object... values) {
|
||||
List<CacheInvocationParameter> result = new ArrayList<>();
|
||||
for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) {
|
||||
int parameterPosition = keyParameterDetail.getParameterPosition();
|
||||
|
||||
@@ -30,6 +30,8 @@ import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheValue;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ExceptionTypeFilter;
|
||||
@@ -105,7 +107,8 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheInvocationParameter[] getAllParameters(Object... values) {
|
||||
@SuppressWarnings("NullAway")
|
||||
public CacheInvocationParameter[] getAllParameters(@Nullable Object... values) {
|
||||
if (this.allParameterDetails.size() != values.length) {
|
||||
throw new IllegalStateException("Values mismatch, operation has " +
|
||||
this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)");
|
||||
@@ -200,7 +203,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
return this.isValue;
|
||||
}
|
||||
|
||||
public CacheInvocationParameter toCacheInvocationParameter(Object value) {
|
||||
public CacheInvocationParameter toCacheInvocationParameter(@Nullable Object value) {
|
||||
return new CacheInvocationParameterImpl(this, value);
|
||||
}
|
||||
}
|
||||
@@ -213,9 +216,9 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
|
||||
private final CacheParameterDetail detail;
|
||||
|
||||
private final Object value;
|
||||
private final @Nullable Object value;
|
||||
|
||||
public CacheInvocationParameterImpl(CacheParameterDetail detail, Object value) {
|
||||
public CacheInvocationParameterImpl(CacheParameterDetail detail, @Nullable Object value) {
|
||||
this.detail = detail;
|
||||
this.value = value;
|
||||
}
|
||||
@@ -226,7 +229,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public @Nullable Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,11 @@ import javax.cache.annotation.CacheRemoveAll;
|
||||
import javax.cache.annotation.CacheResolverFactory;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -58,8 +59,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType) {
|
||||
protected @Nullable JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType) {
|
||||
CacheResult cacheResult = method.getAnnotation(CacheResult.class);
|
||||
CachePut cachePut = method.getAnnotation(CachePut.class);
|
||||
CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class);
|
||||
@@ -88,8 +88,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected CacheDefaults getCacheDefaults(Method method, @Nullable Class<?> targetType) {
|
||||
protected @Nullable CacheDefaults getCacheDefaults(Method method, @Nullable Class<?> targetType) {
|
||||
CacheDefaults annotation = method.getDeclaringClass().getAnnotation(CacheDefaults.class);
|
||||
if (annotation != null) {
|
||||
return annotation;
|
||||
@@ -175,8 +174,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected CacheResolverFactory determineCacheResolverFactory(
|
||||
protected @Nullable CacheResolverFactory determineCacheResolverFactory(
|
||||
@Nullable CacheDefaults defaults, Class<? extends CacheResolverFactory> candidate) {
|
||||
|
||||
if (candidate != CacheResolverFactory.class) {
|
||||
|
||||
@@ -19,11 +19,12 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import javax.cache.annotation.CacheKeyInvocationContext;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
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}.
|
||||
@@ -40,8 +41,7 @@ class CachePutInterceptor extends AbstractKeyCacheInterceptor<CachePutOperation,
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object invoke(
|
||||
protected @Nullable Object invoke(
|
||||
CacheOperationInvocationContext<CachePutOperation> context, CacheOperationInvoker invoker) {
|
||||
|
||||
CachePutOperation operation = context.getOperation();
|
||||
|
||||
@@ -23,9 +23,10 @@ import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ExceptionTypeFilter;
|
||||
|
||||
/**
|
||||
@@ -81,7 +82,7 @@ class CachePutOperation extends AbstractJCacheKeyOperation<CachePut> {
|
||||
* @param values the parameters value for a particular invocation
|
||||
* @return the {@link CacheInvocationParameter} instance for the value parameter
|
||||
*/
|
||||
public CacheInvocationParameter getValueParameter(Object... values) {
|
||||
public CacheInvocationParameter getValueParameter(@Nullable Object... values) {
|
||||
int parameterPosition = this.valueParameterDetail.getParameterPosition();
|
||||
if (parameterPosition >= values.length) {
|
||||
throw new IllegalStateException("Values mismatch, value parameter at position " +
|
||||
@@ -91,8 +92,7 @@ class CachePutOperation extends AbstractJCacheKeyOperation<CachePut> {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static CacheParameterDetail initializeValueParameterDetail(
|
||||
private static @Nullable CacheParameterDetail initializeValueParameterDetail(
|
||||
Method method, List<CacheParameterDetail> allParameters) {
|
||||
|
||||
CacheParameterDetail result = null;
|
||||
|
||||
@@ -18,11 +18,12 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import javax.cache.annotation.CacheRemoveAll;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
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}.
|
||||
@@ -39,8 +40,7 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object invoke(
|
||||
protected @Nullable Object invoke(
|
||||
CacheOperationInvocationContext<CacheRemoveAllOperation> context, CacheOperationInvoker invoker) {
|
||||
|
||||
CacheRemoveAllOperation operation = context.getOperation();
|
||||
|
||||
@@ -18,11 +18,12 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import javax.cache.annotation.CacheRemove;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
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}.
|
||||
@@ -39,8 +40,7 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object invoke(
|
||||
protected @Nullable Object invoke(
|
||||
CacheOperationInvocationContext<CacheRemoveOperation> context, CacheOperationInvoker invoker) {
|
||||
|
||||
CacheRemoveOperation operation = context.getOperation();
|
||||
|
||||
@@ -18,12 +18,13 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvocationContext;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvoker;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ExceptionTypeFilter;
|
||||
import org.springframework.util.SerializationUtils;
|
||||
@@ -43,8 +44,7 @@ class CacheResultInterceptor extends AbstractKeyCacheInterceptor<CacheResultOper
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object invoke(
|
||||
protected @Nullable Object invoke(
|
||||
CacheOperationInvocationContext<CacheResultOperation> context, CacheOperationInvoker invoker) {
|
||||
|
||||
CacheResultOperation operation = context.getOperation();
|
||||
@@ -97,8 +97,7 @@ class CacheResultInterceptor extends AbstractKeyCacheInterceptor<CacheResultOper
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Cache resolveExceptionCache(CacheOperationInvocationContext<CacheResultOperation> context) {
|
||||
private @Nullable Cache resolveExceptionCache(CacheOperationInvocationContext<CacheResultOperation> context) {
|
||||
CacheResolver exceptionCacheResolver = context.getOperation().getExceptionCacheResolver();
|
||||
if (exceptionCacheResolver != null) {
|
||||
return extractFrom(exceptionCacheResolver.resolveCaches(context));
|
||||
@@ -146,8 +145,7 @@ class CacheResultInterceptor extends AbstractKeyCacheInterceptor<CacheResultOper
|
||||
return new CacheOperationInvoker.ThrowableWrapper(clone);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static <T extends Throwable> T cloneException(T exception) {
|
||||
private static <T extends Throwable> @Nullable T cloneException(T exception) {
|
||||
try {
|
||||
return SerializationUtils.clone(exception);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,10 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ExceptionTypeFilter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -36,11 +37,9 @@ class CacheResultOperation extends AbstractJCacheKeyOperation<CacheResult> {
|
||||
|
||||
private final ExceptionTypeFilter exceptionTypeFilter;
|
||||
|
||||
@Nullable
|
||||
private final CacheResolver exceptionCacheResolver;
|
||||
private final @Nullable CacheResolver exceptionCacheResolver;
|
||||
|
||||
@Nullable
|
||||
private final String exceptionCacheName;
|
||||
private final @Nullable String exceptionCacheName;
|
||||
|
||||
|
||||
public CacheResultOperation(CacheMethodDetails<CacheResult> methodDetails, CacheResolver cacheResolver,
|
||||
@@ -73,8 +72,7 @@ class CacheResultOperation extends AbstractJCacheKeyOperation<CacheResult> {
|
||||
* Return the {@link CacheResolver} instance to use to resolve the cache to
|
||||
* use for matching exceptions thrown by this operation.
|
||||
*/
|
||||
@Nullable
|
||||
public CacheResolver getExceptionCacheResolver() {
|
||||
public @Nullable CacheResolver getExceptionCacheResolver() {
|
||||
return this.exceptionCacheResolver;
|
||||
}
|
||||
|
||||
@@ -83,8 +81,7 @@ class CacheResultOperation extends AbstractJCacheKeyOperation<CacheResult> {
|
||||
* caching exceptions should be disabled.
|
||||
* @see javax.cache.annotation.CacheResult#exceptionCacheName()
|
||||
*/
|
||||
@Nullable
|
||||
public String getExceptionCacheName() {
|
||||
public @Nullable String getExceptionCacheName() {
|
||||
return this.exceptionCacheName;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.Set;
|
||||
import javax.cache.annotation.CacheInvocationContext;
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheOperationInvocationContext;
|
||||
|
||||
/**
|
||||
@@ -42,12 +44,12 @@ class DefaultCacheInvocationContext<A extends Annotation>
|
||||
|
||||
private final Object target;
|
||||
|
||||
private final Object[] args;
|
||||
private final @Nullable Object[] args;
|
||||
|
||||
private final CacheInvocationParameter[] allParameters;
|
||||
|
||||
|
||||
public DefaultCacheInvocationContext(JCacheOperation<A> operation, Object target, Object[] args) {
|
||||
public DefaultCacheInvocationContext(JCacheOperation<A> operation, Object target, @Nullable Object[] args) {
|
||||
this.operation = operation;
|
||||
this.target = target;
|
||||
this.args = args;
|
||||
@@ -66,7 +68,7 @@ class DefaultCacheInvocationContext<A extends Annotation>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArgs() {
|
||||
public @Nullable Object[] getArgs() {
|
||||
return this.args.clone();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.lang.annotation.Annotation;
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheKeyInvocationContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* The default {@link CacheKeyInvocationContext} implementation.
|
||||
@@ -35,11 +35,10 @@ class DefaultCacheKeyInvocationContext<A extends Annotation> extends DefaultCach
|
||||
|
||||
private final CacheInvocationParameter[] keyParameters;
|
||||
|
||||
@Nullable
|
||||
private final CacheInvocationParameter valueParameter;
|
||||
private final @Nullable CacheInvocationParameter valueParameter;
|
||||
|
||||
|
||||
public DefaultCacheKeyInvocationContext(AbstractJCacheKeyOperation<A> operation, Object target, Object[] args) {
|
||||
public DefaultCacheKeyInvocationContext(AbstractJCacheKeyOperation<A> operation, Object target, @Nullable Object[] args) {
|
||||
super(operation, target, args);
|
||||
this.keyParameters = operation.getKeyParameters(args);
|
||||
if (operation instanceof CachePutOperation cachePutOperation) {
|
||||
@@ -57,8 +56,7 @@ class DefaultCacheKeyInvocationContext<A extends Annotation> extends DefaultCach
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CacheInvocationParameter getValueParameter() {
|
||||
public @Nullable CacheInvocationParameter getValueParameter() {
|
||||
return this.valueParameter;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -32,7 +34,6 @@ import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.cache.interceptor.SimpleCacheResolver;
|
||||
import org.springframework.cache.interceptor.SimpleKeyGenerator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.function.SingletonSupplier;
|
||||
import org.springframework.util.function.SupplierUtils;
|
||||
@@ -49,22 +50,18 @@ import org.springframework.util.function.SupplierUtils;
|
||||
public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSource
|
||||
implements BeanFactoryAware, SmartInitializingSingleton {
|
||||
|
||||
@Nullable
|
||||
private SingletonSupplier<CacheManager> cacheManager;
|
||||
private @Nullable SingletonSupplier<CacheManager> cacheManager;
|
||||
|
||||
@Nullable
|
||||
private SingletonSupplier<CacheResolver> cacheResolver;
|
||||
private @Nullable SingletonSupplier<CacheResolver> cacheResolver;
|
||||
|
||||
@Nullable
|
||||
private SingletonSupplier<CacheResolver> exceptionCacheResolver;
|
||||
private @Nullable SingletonSupplier<CacheResolver> exceptionCacheResolver;
|
||||
|
||||
private SingletonSupplier<KeyGenerator> keyGenerator;
|
||||
|
||||
private final SingletonSupplier<KeyGenerator> adaptedKeyGenerator =
|
||||
SingletonSupplier.of(() -> new KeyGeneratorAdapter(this, getKeyGenerator()));
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
private @Nullable BeanFactory beanFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -103,8 +100,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
/**
|
||||
* Return the specified cache manager to use, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public CacheManager getCacheManager() {
|
||||
public @Nullable CacheManager getCacheManager() {
|
||||
return SupplierUtils.resolve(this.cacheManager);
|
||||
}
|
||||
|
||||
@@ -119,8 +115,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
/**
|
||||
* Return the specified cache resolver to use, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public CacheResolver getCacheResolver() {
|
||||
public @Nullable CacheResolver getCacheResolver() {
|
||||
return SupplierUtils.resolve(this.cacheResolver);
|
||||
}
|
||||
|
||||
@@ -135,8 +130,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
/**
|
||||
* Return the specified exception cache resolver to use, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public CacheResolver getExceptionCacheResolver() {
|
||||
public @Nullable CacheResolver getExceptionCacheResolver() {
|
||||
return SupplierUtils.resolve(this.exceptionCacheResolver);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aop.framework.AopProxyUtils;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -28,7 +29,6 @@ import org.springframework.cache.interceptor.AbstractCacheInvoker;
|
||||
import org.springframework.cache.interceptor.BasicOperation;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvocationContext;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvoker;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -53,20 +53,15 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private JCacheOperationSource cacheOperationSource;
|
||||
private @Nullable JCacheOperationSource cacheOperationSource;
|
||||
|
||||
@Nullable
|
||||
private CacheResultInterceptor cacheResultInterceptor;
|
||||
private @Nullable CacheResultInterceptor cacheResultInterceptor;
|
||||
|
||||
@Nullable
|
||||
private CachePutInterceptor cachePutInterceptor;
|
||||
private @Nullable CachePutInterceptor cachePutInterceptor;
|
||||
|
||||
@Nullable
|
||||
private CacheRemoveEntryInterceptor cacheRemoveEntryInterceptor;
|
||||
private @Nullable CacheRemoveEntryInterceptor cacheRemoveEntryInterceptor;
|
||||
|
||||
@Nullable
|
||||
private CacheRemoveAllInterceptor cacheRemoveAllInterceptor;
|
||||
private @Nullable CacheRemoveAllInterceptor cacheRemoveAllInterceptor;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
@@ -101,8 +96,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
protected Object execute(CacheOperationInvoker invoker, Object target, Method method, Object[] args) {
|
||||
protected @Nullable Object execute(CacheOperationInvoker invoker, Object target, Method method, Object[] args) {
|
||||
// Check whether aspect is enabled to cope with cases where the AJ is pulled in automatically
|
||||
if (this.initialized) {
|
||||
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
|
||||
@@ -126,8 +120,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
|
||||
private @Nullable Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
|
||||
CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
|
||||
BasicOperation operation = context.getOperation();
|
||||
|
||||
@@ -165,8 +158,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
||||
* @return the result of the invocation
|
||||
* @see CacheOperationInvoker#invoke()
|
||||
*/
|
||||
@Nullable
|
||||
protected Object invokeOperation(CacheOperationInvoker invoker) {
|
||||
protected @Nullable Object invokeOperation(CacheOperationInvoker invoker) {
|
||||
return invoker.invoke();
|
||||
}
|
||||
|
||||
@@ -180,8 +172,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object invoke() throws ThrowableWrapper {
|
||||
public @Nullable Object invoke() throws ThrowableWrapper {
|
||||
return invokeOperation(this.delegate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.interceptor.CacheOperationInvoker;
|
||||
import org.springframework.cache.interceptor.SimpleCacheErrorHandler;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.function.SingletonSupplier;
|
||||
|
||||
@@ -66,8 +66,7 @@ public class JCacheInterceptor extends JCacheAspectSupport implements MethodInte
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||
public @Nullable Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||
Method method = invocation.getMethod();
|
||||
|
||||
CacheOperationInvoker aopAllianceInvoker = () -> {
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.lang.annotation.Annotation;
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.BasicOperation;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
|
||||
@@ -48,6 +50,6 @@ public interface JCacheOperation<A extends Annotation> extends BasicOperation, C
|
||||
* <p>The method arguments must match the signature of the related method invocation
|
||||
* @param values the parameters value for a particular invocation
|
||||
*/
|
||||
CacheInvocationParameter[] getAllParameters(Object... values);
|
||||
CacheInvocationParameter[] getAllParameters(@Nullable Object... values);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface used by {@link JCacheInterceptor}. Implementations know how to source
|
||||
@@ -70,7 +70,6 @@ public interface JCacheOperationSource {
|
||||
* the declaring class of the method must be used)
|
||||
* @return the cache operation for this method, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass);
|
||||
@Nullable JCacheOperation<?> getCacheOperation(Method method, @Nullable Class<?> targetClass);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,10 +19,11 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.support.StaticMethodMatcherPointcut;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -35,8 +36,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@SuppressWarnings("serial")
|
||||
final class JCacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
|
||||
@Nullable
|
||||
private JCacheOperationSource cacheOperationSource;
|
||||
private @Nullable JCacheOperationSource cacheOperationSource;
|
||||
|
||||
|
||||
public JCacheOperationSourcePointcut() {
|
||||
@@ -85,8 +85,7 @@ final class JCacheOperationSourcePointcut extends StaticMethodMatcherPointcut im
|
||||
return (cacheOperationSource == null || cacheOperationSource.isCandidateClass(clazz));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JCacheOperationSource getCacheOperationSource() {
|
||||
private @Nullable JCacheOperationSource getCacheOperationSource() {
|
||||
return cacheOperationSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,9 @@ import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheKeyGenerator;
|
||||
import javax.cache.annotation.CacheKeyInvocationContext;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -43,11 +44,9 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
|
||||
private final JCacheOperationSource cacheOperationSource;
|
||||
|
||||
@Nullable
|
||||
private KeyGenerator keyGenerator;
|
||||
private @Nullable KeyGenerator keyGenerator;
|
||||
|
||||
@Nullable
|
||||
private CacheKeyGenerator cacheKeyGenerator;
|
||||
private @Nullable CacheKeyGenerator cacheKeyGenerator;
|
||||
|
||||
|
||||
/**
|
||||
@@ -85,7 +84,8 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object generate(Object target, Method method, Object... params) {
|
||||
@SuppressWarnings("NullAway")
|
||||
public Object generate(Object target, Method method, @Nullable Object... params) {
|
||||
JCacheOperation<?> operation = this.cacheOperationSource.getCacheOperation(method, target.getClass());
|
||||
if (!(operation instanceof AbstractJCacheKeyOperation)) {
|
||||
throw new IllegalStateException("Invalid operation, should be a key-based operation " + operation);
|
||||
@@ -119,7 +119,7 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private CacheKeyInvocationContext<?> createCacheKeyInvocationContext(
|
||||
Object target, JCacheOperation<?> operation, Object[] params) {
|
||||
Object target, JCacheOperation<?> operation, @Nullable Object[] params) {
|
||||
|
||||
AbstractJCacheKeyOperation<Annotation> keyCacheOperation = (AbstractJCacheKeyOperation<Annotation>) operation;
|
||||
return new DefaultCacheKeyInvocationContext<>(keyCacheOperation, target, params);
|
||||
|
||||
@@ -19,12 +19,13 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.interceptor.AbstractCacheResolver;
|
||||
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
|
||||
@@ -42,8 +43,7 @@ public class SimpleExceptionCacheResolver extends AbstractCacheResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
||||
protected @Nullable Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
||||
BasicOperation operation = context.getOperation();
|
||||
if (!(operation instanceof CacheResultOperation cacheResultOperation)) {
|
||||
throw new IllegalStateException("Could not extract exception cache name from " + operation);
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
* <p>Builds on the AOP infrastructure in org.springframework.aop.framework.
|
||||
* Any POJO can be cache-advised with Spring.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
* and {@link org.springframework.cache.Cache Cache} implementation for
|
||||
* use in a Spring context, using a JSR-107 compliant cache provider.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.cache.jcache;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -20,8 +20,9 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -77,26 +78,22 @@ public class TransactionAwareCacheDecorator implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ValueWrapper get(Object key) {
|
||||
public @Nullable ValueWrapper get(Object key) {
|
||||
return this.targetCache.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T get(Object key, @Nullable Class<T> type) {
|
||||
public <T> @Nullable T get(Object key, @Nullable Class<T> type) {
|
||||
return this.targetCache.get(key, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
public <T> @Nullable T get(Object key, Callable<T> valueLoader) {
|
||||
return this.targetCache.get(key, valueLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CompletableFuture<?> retrieve(Object key) {
|
||||
public @Nullable CompletableFuture<?> retrieve(Object key) {
|
||||
return this.targetCache.retrieve(key);
|
||||
}
|
||||
|
||||
@@ -106,7 +103,7 @@ public class TransactionAwareCacheDecorator implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(final Object key, @Nullable final Object value) {
|
||||
public void put(final Object key, final @Nullable Object value) {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||
@Override
|
||||
@@ -121,8 +118,7 @@ public class TransactionAwareCacheDecorator implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
|
||||
public @Nullable ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
|
||||
return this.targetCache.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,11 @@ package org.springframework.cache.transaction;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -39,8 +40,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class TransactionAwareCacheManagerProxy implements CacheManager, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private CacheManager targetCacheManager;
|
||||
private @Nullable CacheManager targetCacheManager;
|
||||
|
||||
|
||||
/**
|
||||
@@ -76,8 +76,7 @@ public class TransactionAwareCacheManagerProxy implements CacheManager, Initiali
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Cache getCache(String name) {
|
||||
public @Nullable Cache getCache(String name) {
|
||||
Assert.state(this.targetCacheManager != null, "No target CacheManager set");
|
||||
Cache targetCache = this.targetCacheManager.getCache(name);
|
||||
return (targetCache != null ? new TransactionAwareCacheDecorator(targetCache) : null);
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* Transaction-aware decorators for the org.springframework.cache package.
|
||||
* Provides synchronization of put operations with Spring-managed transactions.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.cache.transaction;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
package org.springframework.mail;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for all mail exceptions.
|
||||
|
||||
@@ -21,7 +21,8 @@ import java.io.PrintWriter;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -36,8 +37,7 @@ public class MailSendException extends MailException {
|
||||
|
||||
private final transient Map<Object, Exception> failedMessages;
|
||||
|
||||
@Nullable
|
||||
private final Exception[] messageExceptions;
|
||||
private final Exception @Nullable [] messageExceptions;
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,8 +124,7 @@ public class MailSendException extends MailException {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
public @Nullable String getMessage() {
|
||||
if (ObjectUtils.isEmpty(this.messageExceptions)) {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ package org.springframework.mail;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -44,29 +45,21 @@ import org.springframework.util.StringUtils;
|
||||
@SuppressWarnings("serial")
|
||||
public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
|
||||
@Nullable
|
||||
private String from;
|
||||
private @Nullable String from;
|
||||
|
||||
@Nullable
|
||||
private String replyTo;
|
||||
private @Nullable String replyTo;
|
||||
|
||||
@Nullable
|
||||
private String[] to;
|
||||
private String @Nullable [] to;
|
||||
|
||||
@Nullable
|
||||
private String[] cc;
|
||||
private String @Nullable [] cc;
|
||||
|
||||
@Nullable
|
||||
private String[] bcc;
|
||||
private String @Nullable [] bcc;
|
||||
|
||||
@Nullable
|
||||
private Date sentDate;
|
||||
private @Nullable Date sentDate;
|
||||
|
||||
@Nullable
|
||||
private String subject;
|
||||
private @Nullable String subject;
|
||||
|
||||
@Nullable
|
||||
private String text;
|
||||
private @Nullable String text;
|
||||
|
||||
|
||||
/**
|
||||
@@ -97,8 +90,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFrom() {
|
||||
public @Nullable String getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
|
||||
@@ -107,8 +99,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
this.replyTo = replyTo;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getReplyTo() {
|
||||
public @Nullable String getReplyTo() {
|
||||
return this.replyTo;
|
||||
}
|
||||
|
||||
@@ -122,8 +113,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String[] getTo() {
|
||||
public String @Nullable [] getTo() {
|
||||
return this.to;
|
||||
}
|
||||
|
||||
@@ -133,12 +123,11 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCc(@Nullable String... cc) {
|
||||
public void setCc(String @Nullable ... cc) {
|
||||
this.cc = cc;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String[] getCc() {
|
||||
public String @Nullable [] getCc() {
|
||||
return this.cc;
|
||||
}
|
||||
|
||||
@@ -148,12 +137,11 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBcc(@Nullable String... bcc) {
|
||||
public void setBcc(String @Nullable ... bcc) {
|
||||
this.bcc = bcc;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String[] getBcc() {
|
||||
public String @Nullable [] getBcc() {
|
||||
return this.bcc;
|
||||
}
|
||||
|
||||
@@ -162,8 +150,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
this.sentDate = sentDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getSentDate() {
|
||||
public @Nullable Date getSentDate() {
|
||||
return this.sentDate;
|
||||
}
|
||||
|
||||
@@ -172,8 +159,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSubject() {
|
||||
public @Nullable String getSubject() {
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
@@ -182,8 +168,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
public @Nullable String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@@ -255,8 +240,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static String[] copyOrNull(@Nullable String[] state) {
|
||||
private static String @Nullable [] copyOrNull(String @Nullable [] state) {
|
||||
if (state == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ import java.io.InputStream;
|
||||
|
||||
import jakarta.activation.FileTypeMap;
|
||||
import jakarta.activation.MimetypesFileTypeMap;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Spring-configurable {@code FileTypeMap} implementation that will read
|
||||
@@ -70,15 +70,13 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali
|
||||
/**
|
||||
* Used to configure additional mappings.
|
||||
*/
|
||||
@Nullable
|
||||
private String[] mappings;
|
||||
private String @Nullable [] mappings;
|
||||
|
||||
/**
|
||||
* The delegate FileTypeMap, compiled from the mappings in the mapping file
|
||||
* and the entries in the {@code mappings} property.
|
||||
*/
|
||||
@Nullable
|
||||
private FileTypeMap fileTypeMap;
|
||||
private @Nullable FileTypeMap fileTypeMap;
|
||||
|
||||
|
||||
/**
|
||||
@@ -143,7 +141,7 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali
|
||||
* @see jakarta.activation.MimetypesFileTypeMap#MimetypesFileTypeMap(java.io.InputStream)
|
||||
* @see jakarta.activation.MimetypesFileTypeMap#addMimeTypes(String)
|
||||
*/
|
||||
protected FileTypeMap createFileTypeMap(@Nullable Resource mappingLocation, @Nullable String[] mappings) throws IOException {
|
||||
protected FileTypeMap createFileTypeMap(@Nullable Resource mappingLocation, String @Nullable [] mappings) throws IOException {
|
||||
MimetypesFileTypeMap fileTypeMap = null;
|
||||
if (mappingLocation != null) {
|
||||
try (InputStream is = mappingLocation.getInputStream()) {
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.mail.javamail;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link RuntimeHintsRegistrar} implementation that makes sure mime types
|
||||
|
||||
@@ -32,8 +32,8 @@ import jakarta.mail.NoSuchProviderException;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Transport;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mail.MailAuthenticationException;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.MailParseException;
|
||||
@@ -80,28 +80,21 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
|
||||
private Properties javaMailProperties = new Properties();
|
||||
|
||||
@Nullable
|
||||
private Session session;
|
||||
private @Nullable Session session;
|
||||
|
||||
@Nullable
|
||||
private String protocol;
|
||||
private @Nullable String protocol;
|
||||
|
||||
@Nullable
|
||||
private String host;
|
||||
private @Nullable String host;
|
||||
|
||||
private int port = DEFAULT_PORT;
|
||||
|
||||
@Nullable
|
||||
private String username;
|
||||
private @Nullable String username;
|
||||
|
||||
@Nullable
|
||||
private String password;
|
||||
private @Nullable String password;
|
||||
|
||||
@Nullable
|
||||
private String defaultEncoding;
|
||||
private @Nullable String defaultEncoding;
|
||||
|
||||
@Nullable
|
||||
private FileTypeMap defaultFileTypeMap;
|
||||
private @Nullable FileTypeMap defaultFileTypeMap;
|
||||
|
||||
|
||||
/**
|
||||
@@ -174,8 +167,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
/**
|
||||
* Return the mail protocol.
|
||||
*/
|
||||
@Nullable
|
||||
public String getProtocol() {
|
||||
public @Nullable String getProtocol() {
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
@@ -190,8 +182,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
/**
|
||||
* Return the mail server host.
|
||||
*/
|
||||
@Nullable
|
||||
public String getHost() {
|
||||
public @Nullable String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
@@ -229,8 +220,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
/**
|
||||
* Return the username for the account at the mail host.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUsername() {
|
||||
public @Nullable String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@@ -252,8 +242,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
/**
|
||||
* Return the password for the account at the mail host.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPassword() {
|
||||
public @Nullable String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@@ -270,8 +259,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* Return the default encoding for {@link MimeMessage MimeMessages},
|
||||
* or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDefaultEncoding() {
|
||||
public @Nullable String getDefaultEncoding() {
|
||||
return this.defaultEncoding;
|
||||
}
|
||||
|
||||
@@ -296,8 +284,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* Return the default Java Activation {@link FileTypeMap} for
|
||||
* {@link MimeMessage MimeMessages}, or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
public FileTypeMap getDefaultFileTypeMap() {
|
||||
public @Nullable FileTypeMap getDefaultFileTypeMap() {
|
||||
return this.defaultFileTypeMap;
|
||||
}
|
||||
|
||||
@@ -377,7 +364,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* @throws org.springframework.mail.MailSendException
|
||||
* in case of failure when sending a message
|
||||
*/
|
||||
protected void doSend(MimeMessage[] mimeMessages, @Nullable Object[] originalMessages) throws MailException {
|
||||
protected void doSend(MimeMessage[] mimeMessages, Object @Nullable [] originalMessages) throws MailException {
|
||||
Map<Object, Exception> failedMessages = new LinkedHashMap<>();
|
||||
Transport transport = null;
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
import jakarta.mail.internet.MimePart;
|
||||
import jakarta.mail.internet.MimeUtility;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.io.InputStreamSource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
@@ -165,14 +165,11 @@ public class MimeMessageHelper {
|
||||
|
||||
private final MimeMessage mimeMessage;
|
||||
|
||||
@Nullable
|
||||
private MimeMultipart rootMimeMultipart;
|
||||
private @Nullable MimeMultipart rootMimeMultipart;
|
||||
|
||||
@Nullable
|
||||
private MimeMultipart mimeMultipart;
|
||||
private @Nullable MimeMultipart mimeMultipart;
|
||||
|
||||
@Nullable
|
||||
private final String encoding;
|
||||
private final @Nullable String encoding;
|
||||
|
||||
private FileTypeMap fileTypeMap;
|
||||
|
||||
@@ -426,8 +423,7 @@ public class MimeMessageHelper {
|
||||
* @return the default encoding associated with the MimeMessage,
|
||||
* or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected String getDefaultEncoding(MimeMessage mimeMessage) {
|
||||
protected @Nullable String getDefaultEncoding(MimeMessage mimeMessage) {
|
||||
if (mimeMessage instanceof SmartMimeMessage smartMimeMessage) {
|
||||
return smartMimeMessage.getDefaultEncoding();
|
||||
}
|
||||
@@ -437,8 +433,7 @@ public class MimeMessageHelper {
|
||||
/**
|
||||
* Return the specific character encoding used for this message, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getEncoding() {
|
||||
public @Nullable String getEncoding() {
|
||||
return this.encoding;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.mail.javamail;
|
||||
import jakarta.activation.FileTypeMap;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Special subclass of the standard JavaMail {@link MimeMessage}, carrying a
|
||||
@@ -39,11 +38,9 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
class SmartMimeMessage extends MimeMessage {
|
||||
|
||||
@Nullable
|
||||
private final String defaultEncoding;
|
||||
private final @Nullable String defaultEncoding;
|
||||
|
||||
@Nullable
|
||||
private final FileTypeMap defaultFileTypeMap;
|
||||
private final @Nullable FileTypeMap defaultFileTypeMap;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,16 +61,14 @@ class SmartMimeMessage extends MimeMessage {
|
||||
/**
|
||||
* Return the default encoding of this message, or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
public final String getDefaultEncoding() {
|
||||
public final @Nullable String getDefaultEncoding() {
|
||||
return this.defaultEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default FileTypeMap of this message, or {@code null} if none.
|
||||
*/
|
||||
@Nullable
|
||||
public final FileTypeMap getDefaultFileTypeMap() {
|
||||
public final @Nullable FileTypeMap getDefaultFileTypeMap() {
|
||||
return this.defaultFileTypeMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* Provides an extended JavaMailSender interface and a MimeMessageHelper
|
||||
* class for convenient population of a JavaMail MimeMessage.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.mail.javamail;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
* Spring's generic mail infrastructure.
|
||||
* Concrete implementations are provided in the subpackages.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.mail;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
@@ -30,7 +31,6 @@ import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -70,43 +70,33 @@ public class CronTriggerFactoryBean implements FactoryBean<CronTrigger>, BeanNam
|
||||
);
|
||||
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
private @Nullable String name;
|
||||
|
||||
@Nullable
|
||||
private String group;
|
||||
private @Nullable String group;
|
||||
|
||||
@Nullable
|
||||
private JobDetail jobDetail;
|
||||
private @Nullable JobDetail jobDetail;
|
||||
|
||||
private JobDataMap jobDataMap = new JobDataMap();
|
||||
|
||||
@Nullable
|
||||
private Date startTime;
|
||||
private @Nullable Date startTime;
|
||||
|
||||
private long startDelay = 0;
|
||||
|
||||
@Nullable
|
||||
private String cronExpression;
|
||||
private @Nullable String cronExpression;
|
||||
|
||||
@Nullable
|
||||
private TimeZone timeZone;
|
||||
private @Nullable TimeZone timeZone;
|
||||
|
||||
@Nullable
|
||||
private String calendarName;
|
||||
private @Nullable String calendarName;
|
||||
|
||||
private int priority;
|
||||
|
||||
private int misfireInstruction = CronTrigger.MISFIRE_INSTRUCTION_SMART_POLICY;
|
||||
|
||||
@Nullable
|
||||
private String description;
|
||||
private @Nullable String description;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
private @Nullable String beanName;
|
||||
|
||||
@Nullable
|
||||
private CronTrigger cronTrigger;
|
||||
private @Nullable CronTrigger cronTrigger;
|
||||
|
||||
|
||||
/**
|
||||
@@ -281,8 +271,7 @@ public class CronTriggerFactoryBean implements FactoryBean<CronTrigger>, BeanNam
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CronTrigger getObject() {
|
||||
public @Nullable CronTrigger getObject() {
|
||||
return this.cronTrigger;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.scheduling.quartz;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -50,14 +50,11 @@ import org.springframework.util.Assert;
|
||||
public class JobDetailFactoryBean
|
||||
implements FactoryBean<JobDetail>, BeanNameAware, ApplicationContextAware, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
private @Nullable String name;
|
||||
|
||||
@Nullable
|
||||
private String group;
|
||||
private @Nullable String group;
|
||||
|
||||
@Nullable
|
||||
private Class<? extends Job> jobClass;
|
||||
private @Nullable Class<? extends Job> jobClass;
|
||||
|
||||
private JobDataMap jobDataMap = new JobDataMap();
|
||||
|
||||
@@ -65,20 +62,15 @@ public class JobDetailFactoryBean
|
||||
|
||||
private boolean requestsRecovery = false;
|
||||
|
||||
@Nullable
|
||||
private String description;
|
||||
private @Nullable String description;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
private @Nullable String beanName;
|
||||
|
||||
@Nullable
|
||||
private ApplicationContext applicationContext;
|
||||
private @Nullable ApplicationContext applicationContext;
|
||||
|
||||
@Nullable
|
||||
private String applicationContextJobDataKey;
|
||||
private @Nullable String applicationContextJobDataKey;
|
||||
|
||||
@Nullable
|
||||
private JobDetail jobDetail;
|
||||
private @Nullable JobDetail jobDetail;
|
||||
|
||||
|
||||
/**
|
||||
@@ -218,8 +210,7 @@ public class JobDetailFactoryBean
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JobDetail getObject() {
|
||||
public @Nullable JobDetail getObject() {
|
||||
return this.jobDetail;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Locale;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.SchedulerConfigException;
|
||||
import org.quartz.impl.jdbcjobstore.JobStoreCMT;
|
||||
import org.quartz.impl.jdbcjobstore.SimpleSemaphore;
|
||||
@@ -34,7 +35,6 @@ import org.quartz.utils.DBConnectionManager;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
import org.springframework.jdbc.support.JdbcUtils;
|
||||
import org.springframework.jdbc.support.MetaDataAccessException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subclass of Quartz's {@link JobStoreCMT} class that delegates to a Spring-managed
|
||||
@@ -86,8 +86,7 @@ public class LocalDataSourceJobStore extends JobStoreCMT {
|
||||
public static final String NON_TX_DATA_SOURCE_PREFIX = "springNonTxDataSource.";
|
||||
|
||||
|
||||
@Nullable
|
||||
private DataSource dataSource;
|
||||
private @Nullable DataSource dataSource;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.SchedulerConfigException;
|
||||
import org.quartz.spi.ThreadPool;
|
||||
|
||||
import org.springframework.aot.hint.annotation.Reflective;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -41,8 +41,7 @@ public class LocalTaskExecutorThreadPool implements ThreadPool {
|
||||
/** Logger available to subclasses. */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private Executor taskExecutor;
|
||||
private @Nullable Executor taskExecutor;
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDetail;
|
||||
@@ -36,7 +37,6 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.support.ArgumentConvertingMethodInvoker;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MethodInvoker;
|
||||
@@ -78,27 +78,21 @@ import org.springframework.util.MethodInvoker;
|
||||
public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethodInvoker
|
||||
implements FactoryBean<JobDetail>, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
private @Nullable String name;
|
||||
|
||||
private String group = Scheduler.DEFAULT_GROUP;
|
||||
|
||||
private boolean concurrent = true;
|
||||
|
||||
@Nullable
|
||||
private String targetBeanName;
|
||||
private @Nullable String targetBeanName;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
private @Nullable String beanName;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
private @Nullable ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
private @Nullable BeanFactory beanFactory;
|
||||
|
||||
@Nullable
|
||||
private JobDetail jobDetail;
|
||||
private @Nullable JobDetail jobDetail;
|
||||
|
||||
|
||||
/**
|
||||
@@ -199,8 +193,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
* Overridden to support the {@link #setTargetBeanName "targetBeanName"} feature.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getTargetClass() {
|
||||
public @Nullable Class<?> getTargetClass() {
|
||||
Class<?> targetClass = super.getTargetClass();
|
||||
if (targetClass == null && this.targetBeanName != null) {
|
||||
Assert.state(this.beanFactory != null, "BeanFactory must be set when using 'targetBeanName'");
|
||||
@@ -213,8 +206,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
* Overridden to support the {@link #setTargetBeanName "targetBeanName"} feature.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getTargetObject() {
|
||||
public @Nullable Object getTargetObject() {
|
||||
Object targetObject = super.getTargetObject();
|
||||
if (targetObject == null && this.targetBeanName != null) {
|
||||
Assert.state(this.beanFactory != null, "BeanFactory must be set when using 'targetBeanName'");
|
||||
@@ -225,8 +217,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JobDetail getObject() {
|
||||
public @Nullable JobDetail getObject() {
|
||||
return this.jobDetail;
|
||||
}
|
||||
|
||||
@@ -249,8 +240,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(MethodInvokingJob.class);
|
||||
|
||||
@Nullable
|
||||
private MethodInvoker methodInvoker;
|
||||
private @Nullable MethodInvoker methodInvoker;
|
||||
|
||||
/**
|
||||
* Set the MethodInvoker to use.
|
||||
|
||||
@@ -22,12 +22,12 @@ import java.net.URL;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.spi.ClassLoadHelper;
|
||||
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -44,8 +44,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper {
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(ResourceLoaderClassLoadHelper.class);
|
||||
|
||||
@Nullable
|
||||
private ResourceLoader resourceLoader;
|
||||
private @Nullable ResourceLoader resourceLoader;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,8 +87,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public URL getResource(String name) {
|
||||
public @Nullable URL getResource(String name) {
|
||||
Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized");
|
||||
Resource resource = this.resourceLoader.getResource(name);
|
||||
if (resource.exists()) {
|
||||
@@ -109,8 +107,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
public @Nullable InputStream getResourceAsStream(String name) {
|
||||
Assert.state(this.resourceLoader != null, "ResourceLoaderClassLoadHelper not initialized");
|
||||
Resource resource = this.resourceLoader.getResource(name);
|
||||
if (resource.exists()) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.Calendar;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobListener;
|
||||
@@ -38,7 +39,6 @@ import org.quartz.xml.XMLSchedulingDataProcessor;
|
||||
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
@@ -63,32 +63,23 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
|
||||
|
||||
private boolean overwriteExistingJobs = false;
|
||||
|
||||
@Nullable
|
||||
private String[] jobSchedulingDataLocations;
|
||||
private String @Nullable [] jobSchedulingDataLocations;
|
||||
|
||||
@Nullable
|
||||
private List<JobDetail> jobDetails;
|
||||
private @Nullable List<JobDetail> jobDetails;
|
||||
|
||||
@Nullable
|
||||
private Map<String, Calendar> calendars;
|
||||
private @Nullable Map<String, Calendar> calendars;
|
||||
|
||||
@Nullable
|
||||
private List<Trigger> triggers;
|
||||
private @Nullable List<Trigger> triggers;
|
||||
|
||||
@Nullable
|
||||
private SchedulerListener[] schedulerListeners;
|
||||
private SchedulerListener @Nullable [] schedulerListeners;
|
||||
|
||||
@Nullable
|
||||
private JobListener[] globalJobListeners;
|
||||
private JobListener @Nullable [] globalJobListeners;
|
||||
|
||||
@Nullable
|
||||
private TriggerListener[] globalTriggerListeners;
|
||||
private TriggerListener @Nullable [] globalTriggerListeners;
|
||||
|
||||
@Nullable
|
||||
private PlatformTransactionManager transactionManager;
|
||||
private @Nullable PlatformTransactionManager transactionManager;
|
||||
|
||||
@Nullable
|
||||
protected ResourceLoader resourceLoader;
|
||||
protected @Nullable ResourceLoader resourceLoader;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.scheduling.quartz;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.impl.SchedulerRepository;
|
||||
@@ -24,7 +25,6 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -40,14 +40,11 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class SchedulerAccessorBean extends SchedulerAccessor implements BeanFactoryAware, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private String schedulerName;
|
||||
private @Nullable String schedulerName;
|
||||
|
||||
@Nullable
|
||||
private Scheduler scheduler;
|
||||
private @Nullable Scheduler scheduler;
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
private @Nullable BeanFactory beanFactory;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SchedulerFactory;
|
||||
@@ -44,7 +45,6 @@ import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.SchedulingException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -119,8 +119,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
* @see #setApplicationContext
|
||||
* @see ResourceLoaderClassLoadHelper
|
||||
*/
|
||||
@Nullable
|
||||
public static ResourceLoader getConfigTimeResourceLoader() {
|
||||
public static @Nullable ResourceLoader getConfigTimeResourceLoader() {
|
||||
return configTimeResourceLoaderHolder.get();
|
||||
}
|
||||
|
||||
@@ -133,8 +132,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
* @see #setTaskExecutor
|
||||
* @see LocalTaskExecutorThreadPool
|
||||
*/
|
||||
@Nullable
|
||||
public static Executor getConfigTimeTaskExecutor() {
|
||||
public static @Nullable Executor getConfigTimeTaskExecutor() {
|
||||
return configTimeTaskExecutorHolder.get();
|
||||
}
|
||||
|
||||
@@ -147,8 +145,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
* @see #setDataSource
|
||||
* @see LocalDataSourceJobStore
|
||||
*/
|
||||
@Nullable
|
||||
public static DataSource getConfigTimeDataSource() {
|
||||
public static @Nullable DataSource getConfigTimeDataSource() {
|
||||
return configTimeDataSourceHolder.get();
|
||||
}
|
||||
|
||||
@@ -161,43 +158,32 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
* @see #setNonTransactionalDataSource
|
||||
* @see LocalDataSourceJobStore
|
||||
*/
|
||||
@Nullable
|
||||
public static DataSource getConfigTimeNonTransactionalDataSource() {
|
||||
public static @Nullable DataSource getConfigTimeNonTransactionalDataSource() {
|
||||
return configTimeNonTransactionalDataSourceHolder.get();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private SchedulerFactory schedulerFactory;
|
||||
private @Nullable SchedulerFactory schedulerFactory;
|
||||
|
||||
private Class<? extends SchedulerFactory> schedulerFactoryClass = StdSchedulerFactory.class;
|
||||
|
||||
@Nullable
|
||||
private String schedulerName;
|
||||
private @Nullable String schedulerName;
|
||||
|
||||
@Nullable
|
||||
private Resource configLocation;
|
||||
private @Nullable Resource configLocation;
|
||||
|
||||
@Nullable
|
||||
private Properties quartzProperties;
|
||||
private @Nullable Properties quartzProperties;
|
||||
|
||||
@Nullable
|
||||
private Executor taskExecutor;
|
||||
private @Nullable Executor taskExecutor;
|
||||
|
||||
@Nullable
|
||||
private DataSource dataSource;
|
||||
private @Nullable DataSource dataSource;
|
||||
|
||||
@Nullable
|
||||
private DataSource nonTransactionalDataSource;
|
||||
private @Nullable DataSource nonTransactionalDataSource;
|
||||
|
||||
@Nullable
|
||||
private Map<String, ?> schedulerContextMap;
|
||||
private @Nullable Map<String, ?> schedulerContextMap;
|
||||
|
||||
@Nullable
|
||||
private String applicationContextSchedulerContextKey;
|
||||
private @Nullable String applicationContextSchedulerContextKey;
|
||||
|
||||
@Nullable
|
||||
private JobFactory jobFactory;
|
||||
private @Nullable JobFactory jobFactory;
|
||||
|
||||
private boolean jobFactorySet = false;
|
||||
|
||||
@@ -211,14 +197,11 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
|
||||
private boolean waitForJobsToCompleteOnShutdown = false;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
private @Nullable String beanName;
|
||||
|
||||
@Nullable
|
||||
private ApplicationContext applicationContext;
|
||||
private @Nullable ApplicationContext applicationContext;
|
||||
|
||||
@Nullable
|
||||
private Scheduler scheduler;
|
||||
private @Nullable Scheduler scheduler;
|
||||
|
||||
|
||||
/**
|
||||
@@ -773,8 +756,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Scheduler getObject() {
|
||||
public @Nullable Scheduler getObject() {
|
||||
return this.scheduler;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
package org.springframework.scheduling.quartz;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.aot.hint.MemberCategory;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.scheduling.quartz;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.Scheduler;
|
||||
@@ -28,7 +29,6 @@ import org.quartz.impl.triggers.SimpleTriggerImpl;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -77,19 +77,15 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
|
||||
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
|
||||
);
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
private @Nullable String name;
|
||||
|
||||
@Nullable
|
||||
private String group;
|
||||
private @Nullable String group;
|
||||
|
||||
@Nullable
|
||||
private JobDetail jobDetail;
|
||||
private @Nullable JobDetail jobDetail;
|
||||
|
||||
private JobDataMap jobDataMap = new JobDataMap();
|
||||
|
||||
@Nullable
|
||||
private Date startTime;
|
||||
private @Nullable Date startTime;
|
||||
|
||||
private long startDelay;
|
||||
|
||||
@@ -101,14 +97,11 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
|
||||
|
||||
private int misfireInstruction = SimpleTrigger.MISFIRE_INSTRUCTION_SMART_POLICY;
|
||||
|
||||
@Nullable
|
||||
private String description;
|
||||
private @Nullable String description;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
private @Nullable String beanName;
|
||||
|
||||
@Nullable
|
||||
private SimpleTrigger simpleTrigger;
|
||||
private @Nullable SimpleTrigger simpleTrigger;
|
||||
|
||||
|
||||
/**
|
||||
@@ -275,8 +268,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SimpleTrigger getObject() {
|
||||
public @Nullable SimpleTrigger getObject() {
|
||||
return this.simpleTrigger;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.scheduling.quartz;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.quartz.SchedulerContext;
|
||||
import org.quartz.spi.TriggerFiredBundle;
|
||||
|
||||
@@ -24,7 +25,6 @@ import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.PropertyAccessorFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subclass of {@link AdaptableJobFactory} that also supports Spring-style
|
||||
@@ -46,14 +46,11 @@ import org.springframework.lang.Nullable;
|
||||
public class SpringBeanJobFactory extends AdaptableJobFactory
|
||||
implements ApplicationContextAware, SchedulerContextAware {
|
||||
|
||||
@Nullable
|
||||
private String[] ignoredUnknownProperties;
|
||||
private String @Nullable [] ignoredUnknownProperties;
|
||||
|
||||
@Nullable
|
||||
private ApplicationContext applicationContext;
|
||||
private @Nullable ApplicationContext applicationContext;
|
||||
|
||||
@Nullable
|
||||
private SchedulerContext schedulerContext;
|
||||
private @Nullable SchedulerContext schedulerContext;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
* Triggers as beans in a Spring context. Also provides
|
||||
* convenience classes for implementing Quartz Jobs.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.scheduling.quartz;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@@ -33,12 +33,12 @@ import freemarker.template.SimpleHash;
|
||||
import freemarker.template.TemplateException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -81,28 +81,21 @@ public class FreeMarkerConfigurationFactory {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private Resource configLocation;
|
||||
private @Nullable Resource configLocation;
|
||||
|
||||
@Nullable
|
||||
private Properties freemarkerSettings;
|
||||
private @Nullable Properties freemarkerSettings;
|
||||
|
||||
@Nullable
|
||||
private Map<String, Object> freemarkerVariables;
|
||||
private @Nullable Map<String, Object> freemarkerVariables;
|
||||
|
||||
@Nullable
|
||||
private String defaultEncoding;
|
||||
private @Nullable String defaultEncoding;
|
||||
|
||||
private final List<TemplateLoader> templateLoaders = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private List<TemplateLoader> preTemplateLoaders;
|
||||
private @Nullable List<TemplateLoader> preTemplateLoaders;
|
||||
|
||||
@Nullable
|
||||
private List<TemplateLoader> postTemplateLoaders;
|
||||
private @Nullable List<TemplateLoader> postTemplateLoaders;
|
||||
|
||||
@Nullable
|
||||
private String[] templateLoaderPaths;
|
||||
private String @Nullable [] templateLoaderPaths;
|
||||
|
||||
private ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
|
||||
@@ -418,8 +411,7 @@ public class FreeMarkerConfigurationFactory {
|
||||
* @param templateLoaders the final List of {@code TemplateLoader} instances
|
||||
* @return the aggregate TemplateLoader
|
||||
*/
|
||||
@Nullable
|
||||
protected TemplateLoader getAggregateTemplateLoader(List<TemplateLoader> templateLoaders) {
|
||||
protected @Nullable TemplateLoader getAggregateTemplateLoader(List<TemplateLoader> templateLoaders) {
|
||||
return switch (templateLoaders.size()) {
|
||||
case 0 -> {
|
||||
logger.debug("No FreeMarker TemplateLoaders specified");
|
||||
|
||||
@@ -20,11 +20,11 @@ import java.io.IOException;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.TemplateException;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Factory bean that creates a FreeMarker {@link Configuration} and provides it
|
||||
@@ -57,8 +57,7 @@ import org.springframework.lang.Nullable;
|
||||
public class FreeMarkerConfigurationFactoryBean extends FreeMarkerConfigurationFactory
|
||||
implements FactoryBean<Configuration>, InitializingBean, ResourceLoaderAware {
|
||||
|
||||
@Nullable
|
||||
private Configuration configuration;
|
||||
private @Nullable Configuration configuration;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -68,8 +67,7 @@ public class FreeMarkerConfigurationFactoryBean extends FreeMarkerConfigurationF
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Configuration getObject() {
|
||||
public @Nullable Configuration getObject() {
|
||||
return this.configuration;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ import java.io.Reader;
|
||||
import freemarker.cache.TemplateLoader;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* FreeMarker {@link TemplateLoader} adapter that loads template files via a
|
||||
@@ -68,8 +68,7 @@ public class SpringTemplateLoader implements TemplateLoader {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object findTemplateSource(String name) throws IOException {
|
||||
public @Nullable Object findTemplateSource(String name) throws IOException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Looking for FreeMarker template with name [" + name + "]");
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* <a href="https://freemarker.apache.org/">FreeMarker</a>
|
||||
* within a Spring application context.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
@NullMarked
|
||||
package org.springframework.ui.freemarker;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
Reference in New Issue
Block a user