Add missing @Nullable annotations on parameters
Issue: SPR-15540
This commit is contained in:
@@ -22,6 +22,7 @@ import java.util.function.Function;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
|
||||
import org.springframework.cache.support.AbstractValueAdaptingCache;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -82,7 +83,7 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper get(Object key) {
|
||||
public ValueWrapper get(@Nullable Object key) {
|
||||
if (this.cache instanceof LoadingCache) {
|
||||
Object value = ((LoadingCache<Object, Object>) this.cache).get(key);
|
||||
return toValueWrapper(value);
|
||||
@@ -92,7 +93,8 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T get(Object key, final Callable<T> valueLoader) {
|
||||
@Nullable
|
||||
public <T> T get(@Nullable Object key, final Callable<T> valueLoader) {
|
||||
return (T) fromStoreValue(this.cache.get(key, new LoadFunction(valueLoader)));
|
||||
}
|
||||
|
||||
@@ -102,19 +104,20 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
public void put(@Nullable Object key, @Nullable Object value) {
|
||||
this.cache.put(key, toStoreValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper putIfAbsent(Object key, final Object value) {
|
||||
@Nullable
|
||||
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable final Object value) {
|
||||
PutIfAbsentFunction callable = new PutIfAbsentFunction(value);
|
||||
Object result = this.cache.get(key, callable);
|
||||
return (callable.called ? null : toValueWrapper(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
public void evict(@Nullable Object key) {
|
||||
this.cache.invalidate(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.sf.ehcache.Status;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.support.SimpleValueWrapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -63,14 +64,15 @@ public class EhCacheCache implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper get(Object key) {
|
||||
public ValueWrapper get(@Nullable Object key) {
|
||||
Element element = lookup(key);
|
||||
return toValueWrapper(element);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
@Nullable
|
||||
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
|
||||
Element element = lookup(key);
|
||||
if (element != null) {
|
||||
return (T) element.getObjectValue();
|
||||
@@ -107,7 +109,8 @@ public class EhCacheCache implements Cache {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(Object key, Class<T> type) {
|
||||
@Nullable
|
||||
public <T> T get(@Nullable Object key, Class<T> type) {
|
||||
Element element = this.cache.get(key);
|
||||
Object value = (element != null ? element.getObjectValue() : null);
|
||||
if (value != null && type != null && !type.isInstance(value)) {
|
||||
@@ -117,18 +120,18 @@ public class EhCacheCache implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
public void put(@Nullable Object key, @Nullable Object value) {
|
||||
this.cache.put(new Element(key, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper putIfAbsent(Object key, Object value) {
|
||||
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
|
||||
Element existingElement = this.cache.putIfAbsent(new Element(key, value));
|
||||
return toValueWrapper(existingElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
public void evict(@Nullable Object key) {
|
||||
this.cache.remove(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.cache.processor.EntryProcessorException;
|
||||
import javax.cache.processor.MutableEntry;
|
||||
|
||||
import org.springframework.cache.support.AbstractValueAdaptingCache;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
|
||||
try {
|
||||
return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader);
|
||||
}
|
||||
@@ -85,18 +86,18 @@ public class JCacheCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
public void put(@Nullable Object key, @Nullable Object value) {
|
||||
this.cache.put(key, toStoreValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper putIfAbsent(Object key, Object value) {
|
||||
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
|
||||
boolean set = this.cache.putIfAbsent(key, toStoreValue(value));
|
||||
return (set ? null : get(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
public void evict(@Nullable Object key) {
|
||||
this.cache.remove(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class JCacheManagerFactoryBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ 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,7 +41,7 @@ public class AbstractJCacheConfiguration extends AbstractCachingConfiguration {
|
||||
protected CacheResolver exceptionCacheResolver;
|
||||
|
||||
@Override
|
||||
protected void useCachingConfigurer(CachingConfigurer config) {
|
||||
protected void useCachingConfigurer(@Nullable CachingConfigurer config) {
|
||||
super.useCachingConfigurer(config);
|
||||
if (config instanceof JCacheConfigurer) {
|
||||
this.exceptionCacheResolver = ((JCacheConfigurer) config).exceptionCacheResolver();
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cache.transaction;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -71,22 +72,22 @@ public class TransactionAwareCacheDecorator implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper get(Object key) {
|
||||
public ValueWrapper get(@Nullable Object key) {
|
||||
return this.targetCache.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Object key, Class<T> type) {
|
||||
public <T> T get(@Nullable Object key, Class<T> type) {
|
||||
return this.targetCache.get(key, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
|
||||
return this.targetCache.get(key, valueLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(final Object key, final Object value) {
|
||||
public void put(@Nullable final Object key, @Nullable final Object value) {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
@Override
|
||||
@@ -101,12 +102,12 @@ public class TransactionAwareCacheDecorator implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper putIfAbsent(final Object key, final Object value) {
|
||||
public ValueWrapper putIfAbsent(@Nullable final Object key, @Nullable final Object value) {
|
||||
return this.targetCache.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(final Object key) {
|
||||
public void evict(@Nullable final Object key) {
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ 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;
|
||||
@@ -141,7 +142,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user