Add more @Nullable parameters based on null usage

Issue: SPR-15540
This commit is contained in:
Sebastien Deleuze 2017-05-31 21:35:52 +02:00
parent f9b319d3ba
commit 1f28825f9d
219 changed files with 441 additions and 355 deletions

View File

@ -189,7 +189,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
* @param nestedPath the nested path of the object
* @param rootObject the root object at the top of the path
*/
public void setWrappedInstance(Object object, String nestedPath, Object rootObject) {
public void setWrappedInstance(Object object, String nestedPath, @Nullable Object rootObject) {
this.wrappedObject = ObjectUtils.unwrapOptional(object);
Assert.notNull(this.wrappedObject, "Target object must not be null");
this.nestedPath = (nestedPath != null ? nestedPath : "");
@ -567,7 +567,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
return false;
}
private Object convertIfNecessary(String propertyName, Object oldValue, Object newValue, Class<?> requiredType,
private Object convertIfNecessary(@Nullable String propertyName, @Nullable Object oldValue, Object newValue, Class<?> requiredType,
TypeDescriptor td) throws TypeMismatchException {
try {
return this.typeConverterDelegate.convertIfNecessary(propertyName, oldValue, newValue, requiredType, td);
@ -594,7 +594,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
}
}
protected Object convertForProperty(String propertyName, Object oldValue, Object newValue, TypeDescriptor td)
protected Object convertForProperty(String propertyName, @Nullable Object oldValue, Object newValue, TypeDescriptor td)
throws TypeMismatchException {
return convertIfNecessary(propertyName, oldValue, newValue, td.getType(), td);
@ -886,7 +886,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
return new PropertyValue(tokens.canonicalName, defaultValue);
}
private Object newValue(Class<?> type, TypeDescriptor desc, String name) {
private Object newValue(Class<?> type, @Nullable TypeDescriptor desc, String name) {
try {
if (type.isArray()) {
Class<?> componentType = type.getComponentType();

View File

@ -599,7 +599,7 @@ public abstract class BeanUtils {
* @throws BeansException if the copying failed
* @see BeanWrapper
*/
private static void copyProperties(Object source, Object target, Class<?> editable, String... ignoreProperties)
private static void copyProperties(Object source, Object target, @Nullable Class<?> editable, String... ignoreProperties)
throws BeansException {
Assert.notNull(source, "Source must not be null");

View File

@ -28,6 +28,7 @@ import java.security.PrivilegedExceptionAction;
import org.springframework.core.ResolvableType;
import org.springframework.core.convert.Property;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -147,7 +148,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
}
@Override
public void setWrappedInstance(Object object, String nestedPath, Object rootObject) {
public void setWrappedInstance(Object object, String nestedPath, @Nullable Object rootObject) {
super.setWrappedInstance(object, nestedPath, rootObject);
setIntrospectionClass(getWrappedClass());
}

View File

@ -280,7 +280,7 @@ class ExtendedBeanInfo implements BeanInfo {
PropertyDescriptorUtils.copyNonMethodProperties(original, this);
}
public SimplePropertyDescriptor(String propertyName, Method readMethod, Method writeMethod) throws IntrospectionException {
public SimplePropertyDescriptor(String propertyName, @Nullable Method readMethod, Method writeMethod) throws IntrospectionException {
super(propertyName, null, null);
this.readMethod = readMethod;
this.writeMethod = writeMethod;
@ -371,8 +371,8 @@ class ExtendedBeanInfo implements BeanInfo {
PropertyDescriptorUtils.copyNonMethodProperties(original, this);
}
public SimpleIndexedPropertyDescriptor(String propertyName, Method readMethod, Method writeMethod,
Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException {
public SimpleIndexedPropertyDescriptor(String propertyName, @Nullable Method readMethod, @Nullable Method writeMethod,
@Nullable Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException {
super(propertyName, null, null, null, null);
this.readMethod = readMethod;

View File

@ -145,7 +145,7 @@ class TypeConverterDelegate {
* @throws IllegalArgumentException if type conversion failed
*/
@SuppressWarnings("unchecked")
public <T> T convertIfNecessary(String propertyName, @Nullable Object oldValue, Object newValue,
public <T> T convertIfNecessary(@Nullable String propertyName, @Nullable Object oldValue, Object newValue,
@Nullable Class<T> requiredType, TypeDescriptor typeDescriptor) throws IllegalArgumentException {
// Custom editor for this type?

View File

@ -339,7 +339,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
*/
@Nullable
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName) throws BeansException;
/**
* Resolve the specified dependency against the beans defined in this factory.
@ -357,6 +357,6 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
*/
@Nullable
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;
@Nullable Set<String> autowiredBeanNames, @Nullable TypeConverter typeConverter) throws BeansException;
}

View File

@ -32,7 +32,7 @@ public class BeanExpressionContext {
private final Scope scope;
public BeanExpressionContext(ConfigurableBeanFactory beanFactory, Scope scope) {
public BeanExpressionContext(ConfigurableBeanFactory beanFactory, @Nullable Scope scope) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
this.beanFactory = beanFactory;
this.scope = scope;

View File

@ -102,7 +102,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
* then removed once the BeanFactory completes its bootstrap phase.
* @since 2.5
*/
void setTempClassLoader(ClassLoader tempClassLoader);
void setTempClassLoader(@Nullable ClassLoader tempClassLoader);
/**
* Return the temporary ClassLoader to use for type matching purposes,

View File

@ -279,7 +279,7 @@ public class ConstructorArgumentValues {
* @return the ValueHolder for the argument, or {@code null} if none found
*/
@Nullable
public ValueHolder getGenericArgumentValue(@Nullable Class<?> requiredType, @Nullable String requiredName, Set<ValueHolder> usedValueHolders) {
public ValueHolder getGenericArgumentValue(@Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
for (ValueHolder valueHolder : this.genericArgumentValues) {
if (usedValueHolders != null && usedValueHolders.contains(valueHolder)) {
continue;
@ -351,7 +351,7 @@ public class ConstructorArgumentValues {
* @return the ValueHolder for the argument, or {@code null} if none set
*/
@Nullable
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, Set<ValueHolder> usedValueHolders) {
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
Assert.isTrue(index >= 0, "Index must not be negative");
ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName);
if (valueHolder == null) {

View File

@ -52,7 +52,7 @@ public class TypedStringValue implements BeanMetadataElement {
* Create a new {@link TypedStringValue} for the given String value.
* @param value the String value
*/
public TypedStringValue(String value) {
public TypedStringValue(@Nullable String value) {
setValue(value);
}
@ -62,7 +62,7 @@ public class TypedStringValue implements BeanMetadataElement {
* @param value the String value
* @param targetType the type to convert to
*/
public TypedStringValue(String value, Class<?> targetType) {
public TypedStringValue(@Nullable String value, Class<?> targetType) {
setValue(value);
setTargetType(targetType);
}
@ -73,7 +73,7 @@ public class TypedStringValue implements BeanMetadataElement {
* @param value the String value
* @param targetTypeName the type to convert to
*/
public TypedStringValue(String value, String targetTypeName) {
public TypedStringValue(@Nullable String value, String targetTypeName) {
setValue(value);
setTargetTypeName(targetTypeName);
}
@ -85,13 +85,14 @@ public class TypedStringValue implements BeanMetadataElement {
* for example in BeanFactoryPostProcessors.
* @see PropertyPlaceholderConfigurer
*/
public void setValue(String value) {
public void setValue(@Nullable String value) {
this.value = value;
}
/**
* Return the String value.
*/
@Nullable
public String getValue() {
return this.value;
}

View File

@ -39,6 +39,7 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
import org.springframework.core.CollectionFactory;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@ -272,7 +273,7 @@ public abstract class YamlProcessor {
return result;
}
private void buildFlattenedMap(Map<String, Object> result, Map<String, Object> source, String path) {
private void buildFlattenedMap(Map<String, Object> result, Map<String, Object> source, @Nullable String path) {
for (Entry<String, Object> entry : source.entrySet()) {
String key = entry.getKey();
if (StringUtils.hasText(path)) {

View File

@ -67,7 +67,7 @@ public class Problem {
* @param parseState the {@link ParseState} at the time of the error
* @param location the location within a bean configuration source that triggered the error
*/
public Problem(String message, Location location, ParseState parseState, @Nullable Throwable rootCause) {
public Problem(String message, Location location, @Nullable ParseState parseState, @Nullable Throwable rootCause) {
Assert.notNull(message, "Message must not be null");
Assert.notNull(location, "Location must not be null");
this.message = message;

View File

@ -17,6 +17,7 @@
package org.springframework.beans.factory.parsing;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
/**
* Context that gets passed along a bean definition reading process,
@ -59,11 +60,11 @@ public class ReaderContext {
fatal(message, source, null, ex);
}
public void fatal(String message, Object source, ParseState parseState) {
public void fatal(String message, Object source, @Nullable ParseState parseState) {
fatal(message, source, parseState, null);
}
public void fatal(String message, Object source, ParseState parseState, Throwable cause) {
public void fatal(String message, Object source, @Nullable ParseState parseState, @Nullable Throwable cause) {
Location location = new Location(getResource(), source);
this.problemReporter.fatal(new Problem(message, location, parseState, cause));
}
@ -72,15 +73,15 @@ public class ReaderContext {
error(message, source, null, null);
}
public void error(String message, Object source, Throwable ex) {
public void error(String message, Object source, @Nullable Throwable ex) {
error(message, source, null, ex);
}
public void error(String message, Object source, ParseState parseState) {
public void error(String message, Object source, @Nullable ParseState parseState) {
error(message, source, parseState, null);
}
public void error(String message, Object source, ParseState parseState, Throwable cause) {
public void error(String message, Object source, @Nullable ParseState parseState, @Nullable Throwable cause) {
Location location = new Location(getResource(), source);
this.problemReporter.error(new Problem(message, location, parseState, cause));
}
@ -89,15 +90,15 @@ public class ReaderContext {
warning(message, source, null, null);
}
public void warning(String message, Object source, Throwable ex) {
public void warning(String message, Object source, @Nullable Throwable ex) {
warning(message, source, null, ex);
}
public void warning(String message, Object source, ParseState parseState) {
public void warning(String message, Object source, @Nullable ParseState parseState) {
warning(message, source, parseState, null);
}
public void warning(String message, Object source, ParseState parseState, Throwable cause) {
public void warning(String message, Object source, @Nullable ParseState parseState, @Nullable Throwable cause) {
Location location = new Location(getResource(), source);
this.problemReporter.warning(new Problem(message, location, parseState, cause));
}

View File

@ -334,7 +334,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
}
@Override
public Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException {
public Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName) throws BeansException {
return resolveDependency(descriptor, requestingBeanName, null, null);
}
@ -452,7 +452,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #doCreateBean
*/
@Override
protected Object createBean(String beanName, RootBeanDefinition mbd, Object[] args) throws BeanCreationException {
protected Object createBean(String beanName, RootBeanDefinition mbd, @Nullable Object[] args) throws BeanCreationException {
if (logger.isDebugEnabled()) {
logger.debug("Creating instance of bean '" + beanName + "'");
}
@ -1084,7 +1084,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @see #autowireConstructor
* @see #instantiateBean
*/
protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd, Object[] args) {
protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd, @Nullable Object[] args) {
// Make sure bean class is actually resolved at this point.
Class<?> beanClass = resolveBeanClass(mbd, beanName);
@ -1271,7 +1271,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return a BeanWrapper for the new instance
*/
protected BeanWrapper autowireConstructor(
String beanName, RootBeanDefinition mbd, Constructor<?>[] ctors, @Nullable Object[] explicitArgs) {
String beanName, RootBeanDefinition mbd, @Nullable Constructor<?>[] ctors, @Nullable Object[] explicitArgs) {
return new ConstructorResolver(this).autowireConstructor(beanName, mbd, ctors, explicitArgs);
}

View File

@ -230,7 +230,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
*/
@SuppressWarnings("unchecked")
protected <T> T doGetBean(
final String name, final Class<T> requiredType, final Object[] args, boolean typeCheckOnly)
final String name, @Nullable final Class<T> requiredType, @Nullable final Object[] args, boolean typeCheckOnly)
throws BeansException {
final String beanName = transformedBeanName(name);
@ -708,7 +708,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
@Override
public void setTempClassLoader(ClassLoader tempClassLoader) {
public void setTempClassLoader(@Nullable ClassLoader tempClassLoader) {
this.tempClassLoader = tempClassLoader;
}

View File

@ -20,6 +20,7 @@ import java.util.function.Supplier;
import org.springframework.beans.factory.config.BeanDefinitionCustomizer;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -93,7 +94,7 @@ public class BeanDefinitionBuilder {
* @param beanClassName the class name for the bean that the definition is being created for
* @param factoryMethodName the name of the method to use to construct the bean instance
*/
public static BeanDefinitionBuilder rootBeanDefinition(String beanClassName, String factoryMethodName) {
public static BeanDefinitionBuilder rootBeanDefinition(String beanClassName, @Nullable String factoryMethodName) {
BeanDefinitionBuilder builder = new BeanDefinitionBuilder();
builder.beanDefinition = new RootBeanDefinition();
builder.beanDefinition.setBeanClassName(beanClassName);
@ -114,7 +115,7 @@ public class BeanDefinitionBuilder {
* @param beanClass the {@code Class} of the bean that the definition is being created for
* @param factoryMethodName the name of the method to use to construct the bean instance
*/
public static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass, String factoryMethodName) {
public static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass, @Nullable String factoryMethodName) {
BeanDefinitionBuilder builder = new BeanDefinitionBuilder();
builder.beanDefinition = new RootBeanDefinition();
builder.beanDefinition.setBeanClass(beanClass);

View File

@ -78,7 +78,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
@Override
protected Object instantiateWithMethodInjection(RootBeanDefinition bd, String beanName, BeanFactory owner,
Constructor<?> ctor, Object... args) {
@Nullable Constructor<?> ctor, Object... args) {
// Must generate CGLIB subclass...
return new CglibSubclassCreator(bd, owner).instantiate(ctor, args);

View File

@ -823,7 +823,7 @@ class ConstructorResolver {
* Template method for resolving the specified argument which is supposed to be autowired.
*/
protected Object resolveAutowiredArgument(
MethodParameter param, String beanName, Set<String> autowiredBeanNames, TypeConverter typeConverter) {
MethodParameter param, String beanName, @Nullable Set<String> autowiredBeanNames, TypeConverter typeConverter) {
if (InjectionPoint.class.isAssignableFrom(param.getParameterType())) {
InjectionPoint injectionPoint = currentInjectionPoint.get();

View File

@ -1040,7 +1040,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Override
public Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException {
@Nullable Set<String> autowiredBeanNames, @Nullable TypeConverter typeConverter) throws BeansException {
descriptor.initParameterNameDiscovery(getParameterNameDiscoverer());
if (Optional.class == descriptor.getDependencyType()) {
@ -1065,7 +1065,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Nullable
public Object doResolveDependency(DependencyDescriptor descriptor, String beanName,
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException {
@Nullable Set<String> autowiredBeanNames, @Nullable TypeConverter typeConverter) throws BeansException {
InjectionPoint previousInjectionPoint = ConstructorResolver.setCurrentInjectionPoint(descriptor);
try {

View File

@ -450,7 +450,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
return isDependent(beanName, dependentBeanName, null);
}
private boolean isDependent(String beanName, String dependentBeanName, Set<String> alreadySeen) {
private boolean isDependent(String beanName, String dependentBeanName, @Nullable Set<String> alreadySeen) {
if (alreadySeen != null && alreadySeen.contains(beanName)) {
return false;
}

View File

@ -178,7 +178,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
* @param cargs the constructor argument values to apply
* @param pvs the property values to apply
*/
public RootBeanDefinition(@Nullable Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) {
public RootBeanDefinition(@Nullable Class<?> beanClass, ConstructorArgumentValues cargs, @Nullable MutablePropertyValues pvs) {
super(cargs, pvs);
setBeanClass(beanClass);
}

View File

@ -135,7 +135,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
* Instantiation should use the given constructor and parameters.
*/
protected Object instantiateWithMethodInjection(RootBeanDefinition bd, String beanName, BeanFactory owner,
Constructor<?> ctor, Object... args) {
@Nullable Constructor<?> ctor, Object... args) {
throw new UnsupportedOperationException("Method Injection not supported in SimpleInstantiationStrategy");
}

View File

@ -309,7 +309,7 @@ public class BeanDefinitionParserDelegate {
* @see #populateDefaults(DocumentDefaultsDefinition, DocumentDefaultsDefinition, org.w3c.dom.Element)
* @see #getDefaults()
*/
public void initDefaults(Element root, BeanDefinitionParserDelegate parent) {
public void initDefaults(Element root, @Nullable BeanDefinitionParserDelegate parent) {
populateDefaults(this.defaults, (parent != null ? parent.defaults : null), root);
this.readerContext.fireDefaultsRegistered(this.defaults);
}
@ -417,7 +417,7 @@ public class BeanDefinitionParserDelegate {
* {@link org.springframework.beans.factory.parsing.ProblemReporter}.
*/
@Nullable
public BeanDefinitionHolder parseBeanDefinitionElement(Element ele, BeanDefinition containingBean) {
public BeanDefinitionHolder parseBeanDefinitionElement(Element ele, @Nullable BeanDefinition containingBean) {
String id = ele.getAttribute(ID_ATTRIBUTE);
String nameAttr = ele.getAttribute(NAME_ATTRIBUTE);
@ -907,7 +907,7 @@ public class BeanDefinitionParserDelegate {
* Also used for constructor arguments, "propertyName" being null in this case.
*/
@Nullable
public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) {
public Object parsePropertyValue(Element ele, BeanDefinition bd, @Nullable String propertyName) {
String elementName = (propertyName != null) ?
"<property> element for property '" + propertyName + "'" :
"<constructor-arg> element";
@ -961,7 +961,7 @@ public class BeanDefinitionParserDelegate {
}
}
public Object parsePropertySubElement(Element ele, BeanDefinition bd) {
public Object parsePropertySubElement(Element ele, @Nullable BeanDefinition bd) {
return parsePropertySubElement(ele, bd, null);
}
@ -973,7 +973,7 @@ public class BeanDefinitionParserDelegate {
* {@code <value>} tag that might be created
*/
@Nullable
public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) {
public Object parsePropertySubElement(Element ele, BeanDefinition bd, @Nullable String defaultValueType) {
if (!isDefaultNamespace(ele)) {
return parseNestedCustomElement(ele, bd);
}
@ -1355,7 +1355,7 @@ public class BeanDefinitionParserDelegate {
}
@Nullable
public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) {
public BeanDefinition parseCustomElement(Element ele, @Nullable BeanDefinition containingBd) {
String namespaceUri = getNamespaceURI(ele);
NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
if (handler == null) {
@ -1370,7 +1370,7 @@ public class BeanDefinitionParserDelegate {
}
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(
Element ele, BeanDefinitionHolder definitionHolder, BeanDefinition containingBd) {
Element ele, BeanDefinitionHolder definitionHolder, @Nullable BeanDefinition containingBd) {
BeanDefinitionHolder finalDefinition = definitionHolder;

View File

@ -404,7 +404,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
* @throws org.springframework.mail.MailSendException
* in case of failure when sending a message
*/
protected void doSend(MimeMessage[] mimeMessages, Object[] originalMessages) throws MailException {
protected void doSend(MimeMessage[] mimeMessages, @Nullable Object[] originalMessages) throws MailException {
Map<Object, Exception> failedMessages = new LinkedHashMap<>();
Transport transport = null;

View File

@ -362,7 +362,7 @@ public class MimeMessageHelper {
* will be added to (can be the same as the root multipart object, or an element
* nested underneath the root multipart element)
*/
protected final void setMimeMultiparts(@Nullable MimeMultipart root, MimeMultipart main) {
protected final void setMimeMultiparts(@Nullable MimeMultipart root, @Nullable MimeMultipart main) {
this.rootMimeMultipart = root;
this.mimeMultipart = main;
}

View File

@ -39,6 +39,7 @@ 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.TransactionException;
import org.springframework.transaction.TransactionStatus;
@ -186,7 +187,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
}
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}

View File

@ -458,7 +458,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
}
}
private void logInvalidating(CacheOperationContext context, CacheEvictOperation operation, Object key) {
private void logInvalidating(CacheOperationContext context, CacheEvictOperation operation, @Nullable Object key) {
if (logger.isTraceEnabled()) {
logger.trace("Invalidating " + (key != null ? "cache key [" + key + "]" : "entire cache") +
" for operation " + operation + " on method " + context.metadata.method);

View File

@ -53,7 +53,7 @@ public interface MessageSource {
* otherwise the default message passed as a parameter
* @see java.text.MessageFormat
*/
String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale);
String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale);
/**
* Try to resolve the message. Treat as an error if the message can't be found.

View File

@ -18,6 +18,7 @@ package org.springframework.context;
import org.springframework.beans.factory.Aware;
import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
/**
* Interface to be implemented by any object that wishes to be notified of
@ -73,6 +74,6 @@ public interface ResourceLoaderAware extends Aware {
* @see org.springframework.core.io.support.ResourcePatternResolver
* @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
*/
void setResourceLoader(ResourceLoader resourceLoader);
void setResourceLoader(@Nullable ResourceLoader resourceLoader);
}

View File

@ -210,7 +210,7 @@ public class AnnotatedBeanDefinitionReader {
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag
* @since 5.0
*/
<T> void doRegisterBean(Class<T> annotatedClass, @Nullable Supplier<T> instanceSupplier, String name,
<T> void doRegisterBean(Class<T> annotatedClass, @Nullable Supplier<T> instanceSupplier, @Nullable String name,
@Nullable Class<? extends Annotation>[] qualifiers, BeanDefinitionCustomizer... definitionCustomizers) {
AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);

View File

@ -214,7 +214,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
}
@Override
public <T> void registerBean(@Nullable String beanName, @Nullable Class<T> beanClass, Supplier<T> supplier,
public <T> void registerBean(@Nullable String beanName, @Nullable Class<T> beanClass, @Nullable Supplier<T> supplier,
BeanDefinitionCustomizer... customizers) {
this.reader.doRegisterBean(beanClass, supplier, beanName, null, customizers);

View File

@ -252,7 +252,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
* @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader);
this.componentsIndex = CandidateComponentsIndexLoader.loadIndex(this.resourcePatternResolver.getClassLoader());

View File

@ -193,7 +193,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
}
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
this.resourceLoader = resourceLoader;
if (!this.setMetadataReaderFactoryCalled) {

View File

@ -208,7 +208,7 @@ public abstract class AbstractApplicationEventMulticaster
* @return the pre-filtered list of application listeners for the given event and source type
*/
private Collection<ApplicationListener<?>> retrieveApplicationListeners(
ResolvableType eventType, Class<?> sourceType, ListenerRetriever retriever) {
ResolvableType eventType, Class<?> sourceType, @Nullable ListenerRetriever retriever) {
LinkedList<ApplicationListener<?>> allListeners = new LinkedList<>();
Set<ApplicationListener<?>> listeners;

View File

@ -367,7 +367,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
* @param eventType the resolved event type, if known
* @since 4.2
*/
protected void publishEvent(Object event, ResolvableType eventType) {
protected void publishEvent(Object event, @Nullable ResolvableType eventType) {
Assert.notNull(event, "Event must not be null");
if (logger.isTraceEnabled()) {
logger.trace("Publishing event in " + getDisplayName() + ": " + event);
@ -1250,7 +1250,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
//---------------------------------------------------------------------
@Override
public String getMessage(String code, @Nullable Object args[], String defaultMessage, Locale locale) {
public String getMessage(String code, @Nullable Object args[], @Nullable String defaultMessage, Locale locale) {
return getMessageSource().getMessage(code, args, defaultMessage, locale);
}

View File

@ -134,7 +134,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
@Override
public final String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
public final String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) {
String msg = getMessageInternal(code, args, locale);
if (msg != null) {
return msg;

View File

@ -52,7 +52,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
@Override
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
public String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) {
if (this.parentMessageSource != null) {
return this.parentMessageSource.getMessage(code, args, defaultMessage, locale);
}

View File

@ -419,7 +419,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag
* @since 5.0
*/
public <T> void registerBean(@Nullable String beanName, @Nullable Class<T> beanClass, Supplier<T> supplier,
public <T> void registerBean(@Nullable String beanName, @Nullable Class<T> beanClass, @Nullable Supplier<T> supplier,
BeanDefinitionCustomizer... customizers) {
Assert.isTrue(beanName != null || beanClass != null, "Either bean name or bean class must be specified");

View File

@ -162,7 +162,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
* @see org.springframework.context.ResourceLoaderAware
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
this.resourceLoader = (resourceLoader != null ? resourceLoader : new DefaultResourceLoader());
}

View File

@ -22,6 +22,8 @@ import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.List;
import org.springframework.lang.Nullable;
/**
* ClassFileTransformer-based weaver, allowing for a list of transformers to be
* applied on a class byte array. Normally used inside class loaders.
@ -88,7 +90,7 @@ public class WeavingTransformer {
* @param pd protection domain to be used (can be null)
* @return (possibly transformed) class byte definition
*/
public byte[] transformIfNecessary(String className, String internalName, byte[] bytes, ProtectionDomain pd) {
public byte[] transformIfNecessary(String className, String internalName, byte[] bytes, @Nullable ProtectionDomain pd) {
byte[] result = bytes;
for (ClassFileTransformer cft : this.transformers) {
try {

View File

@ -749,7 +749,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
* @throws javax.management.MalformedObjectNameException
* if the retrieved {@code ObjectName} is malformed
*/
protected ObjectName getObjectName(Object bean, String beanKey) throws MalformedObjectNameException {
protected ObjectName getObjectName(Object bean, @Nullable String beanKey) throws MalformedObjectNameException {
if (bean instanceof SelfNaming) {
return ((SelfNaming) bean).getObjectName();
}

View File

@ -20,6 +20,7 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.springframework.core.SpringProperties;
import org.springframework.lang.Nullable;
/**
* {@link JndiLocatorSupport} subclass with public lookup methods,
@ -59,7 +60,7 @@ public class JndiLocatorDelegate extends JndiLocatorSupport {
}
@Override
public <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException {
public <T> T lookup(String jndiName, @Nullable Class<T> requiredType) throws NamingException {
return super.lookup(jndiName, requiredType);
}

View File

@ -18,6 +18,7 @@ package org.springframework.jndi;
import javax.naming.NamingException;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -87,7 +88,7 @@ public abstract class JndiLocatorSupport extends JndiAccessor {
* @throws NamingException if the JNDI lookup failed
* @see #setResourceRef
*/
protected <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException {
protected <T> T lookup(String jndiName, @Nullable Class<T> requiredType) throws NamingException {
Assert.notNull(jndiName, "'jndiName' must not be null");
String convertedName = convertJndiName(jndiName);
T jndiObject;

View File

@ -206,7 +206,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
@SuppressWarnings("unchecked")
private <T> T doGetSingleton(String name, Class<T> requiredType) throws NamingException {
private <T> T doGetSingleton(String name, @Nullable Class<T> requiredType) throws NamingException {
synchronized (this.singletonObjects) {
if (this.singletonObjects.containsKey(name)) {
Object jndiObject = this.singletonObjects.get(name);

View File

@ -20,6 +20,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.springframework.lang.Nullable;
import org.springframework.util.concurrent.FailureCallback;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
@ -54,7 +55,7 @@ public class AsyncResult<V> implements ListenableFuture<V> {
* Create a new AsyncResult holder.
* @param value the value to pass through
*/
public AsyncResult(V value) {
public AsyncResult(@Nullable V value) {
this(value, null);
}
@ -62,7 +63,7 @@ public class AsyncResult<V> implements ListenableFuture<V> {
* Create a new AsyncResult holder.
* @param value the value to pass through
*/
private AsyncResult(V value, ExecutionException ex) {
private AsyncResult(@Nullable V value, @Nullable ExecutionException ex) {
this.value = value;
this.executionException = ex;
}

View File

@ -28,6 +28,7 @@ import javax.enterprise.concurrent.ManagedTask;
import org.springframework.core.task.AsyncListenableTaskExecutor;
import org.springframework.core.task.TaskDecorator;
import org.springframework.core.task.support.TaskExecutorAdapter;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.SchedulingAwareRunnable;
import org.springframework.scheduling.SchedulingTaskExecutor;
import org.springframework.util.ClassUtils;
@ -105,7 +106,7 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
* <p>Autodetects a JSR-236 {@link javax.enterprise.concurrent.ManagedExecutorService}
* in order to expose {@link javax.enterprise.concurrent.ManagedTask} adapters for it.
*/
public final void setConcurrentExecutor(Executor concurrentExecutor) {
public final void setConcurrentExecutor(@Nullable Executor concurrentExecutor) {
if (concurrentExecutor != null) {
this.concurrentExecutor = concurrentExecutor;
if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) {

View File

@ -85,7 +85,7 @@ public abstract class BshScriptUtils {
* @return the scripted Java object
* @throws EvalError in case of BeanShell parsing failure
*/
public static Object createBshObject(String scriptSource, @Nullable Class<?>[] scriptInterfaces, ClassLoader classLoader)
public static Object createBshObject(String scriptSource, @Nullable Class<?>[] scriptInterfaces, @Nullable ClassLoader classLoader)
throws EvalError {
Object result = evaluateBshScript(scriptSource, scriptInterfaces, classLoader);

View File

@ -228,7 +228,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
}
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}

View File

@ -92,7 +92,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
@Override
public void reject(String errorCode, @Nullable Object[] errorArgs, String defaultMessage) {
public void reject(String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
addError(new ObjectError(getObjectName(), resolveMessageCodes(errorCode), errorArgs, defaultMessage));
}

View File

@ -115,7 +115,7 @@ public class BindException extends Exception implements BindingResult {
}
@Override
public void reject(String errorCode, @Nullable Object[] errorArgs, String defaultMessage) {
public void reject(String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
this.bindingResult.reject(errorCode, errorArgs, defaultMessage);
}

View File

@ -164,13 +164,13 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
return StringUtils.toStringArray(codeList);
}
private void addCodes(Collection<String> codeList, String errorCode, String objectName, Iterable<String> fields) {
private void addCodes(Collection<String> codeList, String errorCode, @Nullable String objectName, Iterable<String> fields) {
for (String field : fields) {
addCode(codeList, errorCode, objectName, field);
}
}
private void addCode(Collection<String> codeList, String errorCode, String objectName, String field) {
private void addCode(Collection<String> codeList, String errorCode, @Nullable String objectName, @Nullable String field) {
codeList.add(postProcessMessageCode(this.formatter.format(errorCode, objectName, field)));
}

View File

@ -121,7 +121,7 @@ public interface Errors {
* (can be {@code null})
* @param defaultMessage fallback default message
*/
void reject(String errorCode, @Nullable Object[] errorArgs, String defaultMessage);
void reject(String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage);
/**
* Register a field error for the specified field of the current object

View File

@ -160,7 +160,7 @@ public abstract class ValidationUtils {
* @param defaultMessage fallback default message
*/
public static void rejectIfEmpty(
Errors errors, String field, String errorCode, @Nullable Object[] errorArgs, String defaultMessage) {
Errors errors, String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
Assert.notNull(errors, "Errors object must not be null");
Object value = errors.getFieldValue(field);
@ -240,7 +240,7 @@ public abstract class ValidationUtils {
* @param defaultMessage fallback default message
*/
public static void rejectIfEmptyOrWhitespace(
Errors errors, String field, String errorCode, @Nullable Object[] errorArgs, String defaultMessage) {
Errors errors, String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
Assert.notNull(errors, "Errors object must not be null");
Object value = errors.getFieldValue(field);

View File

@ -74,7 +74,7 @@ public class OrderComparator implements Comparator<Object> {
return doCompare(o1, o2, null);
}
private int doCompare(Object o1, Object o2, OrderSourceProvider sourceProvider) {
private int doCompare(Object o1, Object o2, @Nullable OrderSourceProvider sourceProvider) {
boolean p1 = (o1 instanceof PriorityOrdered);
boolean p2 = (o2 instanceof PriorityOrdered);
if (p1 && !p2) {

View File

@ -122,7 +122,7 @@ public class ReactiveAdapterRegistry {
* (i.e. to adapt from; may be {@code null} if the reactive type is specified)
*/
@Nullable
public ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, Object source) {
public ReactiveAdapter getAdapter(@Nullable Class<?> reactiveType, @Nullable Object source) {
Object sourceToUse = (source instanceof Optional ? ((Optional<?>) source).orElse(null) : source);
Class<?> clazz = (sourceToUse != null ? sourceToUse.getClass() : reactiveType);

View File

@ -17,6 +17,7 @@ package org.springframework.core;
import java.util.function.Supplier;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -42,7 +43,7 @@ public class ReactiveTypeDescriptor {
/**
* Private constructor. See static factory methods.
*/
private ReactiveTypeDescriptor(Class<?> reactiveType, Supplier<?> emptySupplier,
private ReactiveTypeDescriptor(Class<?> reactiveType, @Nullable Supplier<?> emptySupplier,
boolean multiValue, boolean canBeEmpty, boolean noValue) {
Assert.notNull(reactiveType, "'reactiveType' must not be null");

View File

@ -146,7 +146,7 @@ public class ResolvableType implements Serializable {
* with upfront resolution and a pre-calculated hash.
* @since 4.2
*/
private ResolvableType(Type type, TypeProvider typeProvider, VariableResolver variableResolver, Integer hash) {
private ResolvableType(@Nullable Type type, @Nullable TypeProvider typeProvider, @Nullable VariableResolver variableResolver, Integer hash) {
this.type = type;
this.typeProvider = typeProvider;
this.variableResolver = variableResolver;
@ -160,7 +160,7 @@ public class ResolvableType implements Serializable {
* with upfront resolution but lazily calculated hash.
*/
private ResolvableType(
Type type, TypeProvider typeProvider, VariableResolver variableResolver, ResolvableType componentType) {
Type type, @Nullable TypeProvider typeProvider, @Nullable VariableResolver variableResolver, ResolvableType componentType) {
this.type = type;
this.typeProvider = typeProvider;
@ -257,7 +257,7 @@ public class ResolvableType implements Serializable {
return isAssignableFrom(other, null);
}
private boolean isAssignableFrom(ResolvableType other, Map<Type, Type> matchedBefore) {
private boolean isAssignableFrom(ResolvableType other, @Nullable Map<Type, Type> matchedBefore) {
Assert.notNull(other, "ResolvableType must not be null");
// If we cannot resolve types, we are not assignable
@ -700,7 +700,7 @@ public class ResolvableType implements Serializable {
* @see #getGenerics()
* @see #resolve()
*/
public Class<?>[] resolveGenerics(Class<?> fallback) {
public Class<?>[] resolveGenerics(@Nullable Class<?> fallback) {
ResolvableType[] generics = getGenerics();
Class<?>[] resolvedGenerics = new Class<?>[generics.length];
for (int i = 0; i < generics.length; i++) {

View File

@ -241,8 +241,8 @@ public class AnnotatedElementUtils {
return hasMetaAnnotationTypes(element, null, annotationName);
}
private static boolean hasMetaAnnotationTypes(AnnotatedElement element, Class<? extends Annotation> annotationType,
String annotationName) {
private static boolean hasMetaAnnotationTypes(AnnotatedElement element, @Nullable Class<? extends Annotation> annotationType,
@Nullable String annotationName) {
return Boolean.TRUE.equals(
searchWithGetSemantics(element, annotationType, annotationName, new SimpleAnnotationProcessor<Boolean>() {
@ -844,8 +844,8 @@ public class AnnotatedElementUtils {
* @return the result of the processor, potentially {@code null}
*/
@Nullable
private static <T> T searchWithGetSemantics(AnnotatedElement element, Class<? extends Annotation> annotationType,
String annotationName, Processor<T> processor) {
private static <T> T searchWithGetSemantics(AnnotatedElement element, @Nullable Class<? extends Annotation> annotationType,
@Nullable String annotationName, Processor<T> processor) {
return searchWithGetSemantics(element, annotationType, annotationName, null, processor);
}
@ -866,7 +866,7 @@ public class AnnotatedElementUtils {
*/
@Nullable
private static <T> T searchWithGetSemantics(AnnotatedElement element, Class<? extends Annotation> annotationType,
String annotationName, @Nullable Class<? extends Annotation> containerType, Processor<T> processor) {
@Nullable String annotationName, @Nullable Class<? extends Annotation> containerType, Processor<T> processor) {
try {
return searchWithGetSemantics(element, annotationType, annotationName, containerType, processor,
@ -896,8 +896,8 @@ public class AnnotatedElementUtils {
* @return the result of the processor, potentially {@code null}
*/
@Nullable
private static <T> T searchWithGetSemantics(AnnotatedElement element, Class<? extends Annotation> annotationType,
String annotationName, @Nullable Class<? extends Annotation> containerType, Processor<T> processor,
private static <T> T searchWithGetSemantics(AnnotatedElement element, @Nullable Class<? extends Annotation> annotationType,
@Nullable String annotationName, @Nullable Class<? extends Annotation> containerType, Processor<T> processor,
Set<AnnotatedElement> visited, int metaDepth) {
Assert.notNull(element, "AnnotatedElement must not be null");
@ -1029,8 +1029,8 @@ public class AnnotatedElementUtils {
* @since 4.2
*/
@Nullable
private static <T> T searchWithFindSemantics(AnnotatedElement element, Class<? extends Annotation> annotationType,
String annotationName, Processor<T> processor) {
private static <T> T searchWithFindSemantics(AnnotatedElement element, @Nullable Class<? extends Annotation> annotationType,
@Nullable String annotationName, Processor<T> processor) {
return searchWithFindSemantics(element, annotationType, annotationName, null, processor);
}
@ -1051,7 +1051,7 @@ public class AnnotatedElementUtils {
*/
@Nullable
private static <T> T searchWithFindSemantics(AnnotatedElement element, Class<? extends Annotation> annotationType,
String annotationName, @Nullable Class<? extends Annotation> containerType, Processor<T> processor) {
@Nullable String annotationName, @Nullable Class<? extends Annotation> containerType, Processor<T> processor) {
if (containerType != null && !processor.aggregates()) {
throw new IllegalArgumentException(

View File

@ -48,7 +48,7 @@ public class ByteArrayDecoder extends AbstractDecoder<byte[]> {
}
@Override
public Flux<byte[]> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
public Flux<byte[]> decode(Publisher<DataBuffer> inputStream,@Nullable ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return Flux.from(inputStream).map((dataBuffer) -> {

View File

@ -50,7 +50,7 @@ public class ByteBufferDecoder extends AbstractDecoder<ByteBuffer> {
}
@Override
public Flux<ByteBuffer> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
public Flux<ByteBuffer> decode(Publisher<DataBuffer> inputStream, @Nullable ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return Flux.from(inputStream).map((dataBuffer) -> {

View File

@ -50,7 +50,7 @@ public class DataBufferDecoder extends AbstractDecoder<DataBuffer> {
}
@Override
public Flux<DataBuffer> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
public Flux<DataBuffer> decode(Publisher<DataBuffer> inputStream, @Nullable ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return Flux.from(inputStream);
}

View File

@ -58,7 +58,7 @@ public interface Decoder<T> {
* @param hints additional information about how to do encode
* @return the output stream with decoded elements
*/
Flux<T> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
Flux<T> decode(Publisher<DataBuffer> inputStream, @Nullable ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints);
/**

View File

@ -55,7 +55,7 @@ public class ResourceDecoder extends AbstractDecoder<Resource> {
}
@Override
public Flux<Resource> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
public Flux<Resource> decode(Publisher<DataBuffer> inputStream, @Nullable ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
return Flux.from(decodeToMono(inputStream, elementType, mimeType, hints));

View File

@ -77,7 +77,7 @@ public class StringDecoder extends AbstractDecoder<String> {
}
@Override
public Flux<String> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
public Flux<String> decode(Publisher<DataBuffer> inputStream, @Nullable ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
Flux<DataBuffer> inputFlux = Flux.from(inputStream);

View File

@ -16,6 +16,7 @@
package org.springframework.core.convert;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -42,7 +43,7 @@ public class ConversionFailedException extends ConversionException {
* @param value the value we tried to convert
* @param cause the cause of the conversion failure
*/
public ConversionFailedException(TypeDescriptor sourceType, TypeDescriptor targetType, Object value, Throwable cause) {
public ConversionFailedException(TypeDescriptor sourceType, TypeDescriptor targetType, @Nullable Object value, Throwable cause) {
super("Failed to convert from type [" + sourceType + "] to type [" + targetType +
"] for value '" + ObjectUtils.nullSafeToString(value) + "'", cause);
this.sourceType = sourceType;

View File

@ -63,7 +63,7 @@ public final class Property {
private Annotation[] annotations;
public Property(Class<?> objectType, Method readMethod, Method writeMethod) {
public Property(Class<?> objectType, @Nullable Method readMethod, @Nullable Method writeMethod) {
this(objectType, readMethod, writeMethod, null);
}

View File

@ -118,7 +118,7 @@ public class TypeDescriptor implements Serializable {
* @param annotations the type annotations
* @since 4.0
*/
protected TypeDescriptor(ResolvableType resolvableType, @Nullable Class<?> type, Annotation[] annotations) {
protected TypeDescriptor(ResolvableType resolvableType, @Nullable Class<?> type, @Nullable Annotation[] annotations) {
this.resolvableType = resolvableType;
this.type = (type != null ? type : resolvableType.resolve(Object.class));
this.annotatedElement = new AnnotatedElementAdapter(annotations);

View File

@ -230,7 +230,7 @@ public class GenericConversionService implements ConfigurableConversionService {
* @return the converted null object
*/
@Nullable
protected Object convertNullSource(TypeDescriptor sourceType, TypeDescriptor targetType) {
protected Object convertNullSource(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) {
if (targetType.getObjectType() == Optional.class) {
return Optional.empty();
}
@ -317,7 +317,7 @@ public class GenericConversionService implements ConfigurableConversionService {
throw new ConverterNotFoundException(sourceType, targetType);
}
private Object handleResult(TypeDescriptor sourceType, TypeDescriptor targetType, Object result) {
private Object handleResult(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType, Object result) {
if (result == null) {
assertNotPrimitiveTargetType(sourceType, targetType);
}

View File

@ -25,6 +25,7 @@ import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
import org.springframework.lang.Nullable;
import org.springframework.util.ReflectionUtils;
/**
@ -95,7 +96,7 @@ public abstract class VfsUtils {
}
}
protected static Object invokeVfsMethod(Method method, Object target, Object... args) throws IOException {
protected static Object invokeVfsMethod(Method method, @Nullable Object target, Object... args) throws IOException {
try {
return method.invoke(target, args);
}

View File

@ -23,6 +23,7 @@ import java.util.Properties;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
/**
@ -124,7 +125,7 @@ public class ResourcePropertySource extends PropertiesPropertySource {
this(new DefaultResourceLoader().getResource(location));
}
private ResourcePropertySource(String name, String resourceName, Map<String, Object> source) {
private ResourcePropertySource(String name, @Nullable String resourceName, Map<String, Object> source) {
super(name, source);
this.resourceName = resourceName;
}

View File

@ -25,6 +25,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.lang.Nullable;
/**
* {@link PathMatcher} implementation for Ant-style path patterns.
*
@ -187,7 +189,7 @@ public class AntPathMatcher implements PathMatcher {
* as far as the given base path goes is sufficient)
* @return {@code true} if the supplied {@code path} matched, {@code false} if it didn't
*/
protected boolean doMatch(String pattern, String path, boolean fullMatch, Map<String, String> uriTemplateVariables) {
protected boolean doMatch(String pattern, String path, boolean fullMatch, @Nullable Map<String, String> uriTemplateVariables) {
if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
return false;
}

View File

@ -411,7 +411,7 @@ public abstract class CollectionUtils {
}
@Override
public void add(K key, V value) {
public void add(K key, @Nullable V value) {
List<V> values = this.map.computeIfAbsent(key, k -> new LinkedList<>());
values.add(value);
}

View File

@ -24,6 +24,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.lang.Nullable;
/**
* Simple implementation of {@link MultiValueMap} that wraps a {@link LinkedHashMap},
* storing multiple values in a {@link LinkedList}.
@ -74,7 +76,7 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
// MultiValueMap implementation
@Override
public void add(K key, V value) {
public void add(K key, @Nullable V value) {
List<V> values = this.targetMap.computeIfAbsent(key, k -> new LinkedList<>());
values.add(value);
}

View File

@ -42,7 +42,7 @@ public interface MultiValueMap<K, V> extends Map<K, List<V>> {
* @param key the key
* @param value the value to be added
*/
void add(K key, V value);
void add(K key, @Nullable V value);
/**
* Add all the values of the given list to the current list of values for the given key.

View File

@ -238,7 +238,7 @@ public abstract class ReflectionUtils {
* @see #invokeJdbcMethod(java.lang.reflect.Method, Object, Object[])
*/
@Nullable
public static Object invokeJdbcMethod(Method method, Object target) throws SQLException {
public static Object invokeJdbcMethod(Method method, @Nullable Object target) throws SQLException {
return invokeJdbcMethod(method, target, new Object[0]);
}
@ -547,7 +547,7 @@ public abstract class ReflectionUtils {
* @param mf the filter that determines the methods to apply the callback to
* @throws IllegalStateException if introspection fails
*/
public static void doWithMethods(Class<?> clazz, MethodCallback mc, MethodFilter mf) {
public static void doWithMethods(Class<?> clazz, MethodCallback mc, @Nullable MethodFilter mf) {
// Keep backing up the inheritance hierarchy.
Method[] methods = getDeclaredMethods(clazz);
for (Method method : methods) {
@ -720,7 +720,7 @@ public abstract class ReflectionUtils {
* @param ff the filter that determines the fields to apply the callback to
* @throws IllegalStateException if introspection fails
*/
public static void doWithFields(Class<?> clazz, FieldCallback fc, FieldFilter ff) {
public static void doWithFields(Class<?> clazz, FieldCallback fc, @Nullable FieldFilter ff) {
// Keep backing up the inheritance hierarchy.
Class<?> targetClass = clazz;
do {

View File

@ -1065,7 +1065,7 @@ public abstract class StringUtils {
*/
@Nullable
public static Properties splitArrayElementsIntoProperties(
String[] array, String delimiter, String charsToDelete) {
String[] array, String delimiter, @Nullable String charsToDelete) {
if (ObjectUtils.isEmpty(array)) {
return null;
@ -1179,7 +1179,7 @@ public abstract class StringUtils {
* @return an array of the tokens in the list
* @see #tokenizeToStringArray
*/
public static String[] delimitedListToStringArray(String str, String delimiter, String charsToDelete) {
public static String[] delimitedListToStringArray(String str, String delimiter, @Nullable String charsToDelete) {
if (str == null) {
return new String[0];
}

View File

@ -20,6 +20,8 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import org.springframework.lang.Nullable;
/**
* Extension of {@link FutureTask} that implements {@link ListenableFuture}.
*
@ -47,7 +49,7 @@ public class ListenableFutureTask<T> extends FutureTask<T> implements Listenable
* @param runnable the runnable task
* @param result the result to return on successful completion
*/
public ListenableFutureTask(Runnable runnable, T result) {
public ListenableFutureTask(Runnable runnable, @Nullable T result) {
super(runnable, result);
}

View File

@ -21,6 +21,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -54,7 +55,7 @@ public class SettableListenableFuture<T> implements ListenableFuture<T> {
* @param value the value that will be set
* @return {@code true} if the value was successfully set, else {@code false}
*/
public boolean set(T value) {
public boolean set(@Nullable T value) {
return this.settableTask.setResultValue(value);
}

View File

@ -17,6 +17,7 @@
package org.springframework.expression;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@ -43,7 +44,7 @@ public class TypedValue {
* is inferred from the object, so no generic declarations are preserved.
* @param value the object value
*/
public TypedValue(Object value) {
public TypedValue(@Nullable Object value) {
this.value = value;
this.typeDescriptor = null; // initialized when/if requested
}
@ -54,12 +55,13 @@ public class TypedValue {
* @param value the object value
* @param typeDescriptor a type descriptor describing the type of the value
*/
public TypedValue(Object value, TypeDescriptor typeDescriptor) {
public TypedValue(@Nullable Object value, @Nullable TypeDescriptor typeDescriptor) {
this.value = value;
this.typeDescriptor = typeDescriptor;
}
@Nullable
public Object getValue() {
return this.value;
}

View File

@ -21,6 +21,7 @@ import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.TypedValue;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
/**
@ -44,7 +45,7 @@ public abstract class ExpressionUtils {
* of the value to the specified type is not supported
*/
@SuppressWarnings("unchecked")
public static <T> T convertTypedValue(EvaluationContext context, TypedValue typedValue, Class<T> targetType) {
public static <T> T convertTypedValue(@Nullable EvaluationContext context, TypedValue typedValue, Class<T> targetType) {
Object value = typedValue.getValue();
if (targetType == null) {
return (T) value;

View File

@ -24,6 +24,7 @@ import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.ParserContext;
import org.springframework.lang.Nullable;
/**
* An expression parser that understands templates. It can be subclassed by expression
@ -255,7 +256,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
* @return an evaluator for the parsed expression
* @throws ParseException an exception occurred during parsing
*/
protected abstract Expression doParseExpression(String expressionString, ParserContext context)
protected abstract Expression doParseExpression(String expressionString, @Nullable ParserContext context)
throws ParseException;

View File

@ -18,6 +18,7 @@ package org.springframework.expression.spel;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.lang.Nullable;
/**
* Base superclass for compiled expressions. Each generated compiled expression class
@ -33,6 +34,6 @@ public abstract class CompiledExpression {
* Subclasses of CompiledExpression generated by SpelCompiler will provide an
* implementation of this method.
*/
public abstract Object getValue(Object target, EvaluationContext context) throws EvaluationException;
public abstract Object getValue(Object target, @Nullable EvaluationContext context) throws EvaluationException;
}

View File

@ -217,7 +217,7 @@ public class ExpressionState {
return null;
}
public TypedValue operate(Operation op, Object left, Object right) throws EvaluationException {
public TypedValue operate(Operation op, Object left, @Nullable Object right) throws EvaluationException {
OperatorOverloader overloader = this.relatedContext.getOperatorOverloader();
if (overloader.overridesOperation(op, left, right)) {
Object returnValue = overloader.operate(op, left, right);

View File

@ -17,6 +17,7 @@
package org.springframework.expression.spel;
import org.springframework.core.SpringProperties;
import org.springframework.lang.Nullable;
/**
@ -62,7 +63,7 @@ public class SpelParserConfiguration {
* @param compilerMode the compiler mode for the parser
* @param compilerClassLoader the ClassLoader to use as the basis for expression compilation
*/
public SpelParserConfiguration(SpelCompilerMode compilerMode, ClassLoader compilerClassLoader) {
public SpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, ClassLoader compilerClassLoader) {
this(compilerMode, compilerClassLoader, false, false, Integer.MAX_VALUE);
}

View File

@ -19,6 +19,7 @@ package org.springframework.expression.spel.ast;
import java.util.List;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
/**
@ -60,7 +61,7 @@ public class FormatHelper {
* @return a formatted String suitable for message inclusion
* @see ClassUtils#getQualifiedName(Class)
*/
public static String formatClassNameForMessage(Class<?> clazz) {
public static String formatClassNameForMessage(@Nullable Class<?> clazz) {
return (clazz != null ? ClassUtils.getQualifiedName(clazz) : "null");
}

View File

@ -117,7 +117,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
@Override
protected SpelExpression doParseExpression(String expressionString, ParserContext context) throws ParseException {
protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException {
try {
this.expressionString = expressionString;
Tokenizer tokenizer = new Tokenizer(expressionString);

View File

@ -20,6 +20,7 @@ import org.springframework.expression.ParseException;
import org.springframework.expression.ParserContext;
import org.springframework.expression.common.TemplateAwareExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -56,7 +57,7 @@ public class SpelExpressionParser extends TemplateAwareExpressionParser {
}
@Override
protected SpelExpression doParseExpression(String expressionString, ParserContext context) throws ParseException {
protected SpelExpression doParseExpression(String expressionString, @Nullable ParserContext context) throws ParseException {
return new InternalSpelExpressionParser(this.configuration).doParseExpression(expressionString, context);
}

View File

@ -34,6 +34,7 @@ import org.springframework.expression.TypeComparator;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.TypeLocator;
import org.springframework.expression.TypedValue;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -84,7 +85,7 @@ public class StandardEvaluationContext implements EvaluationContext {
this.rootObject = new TypedValue(rootObject, typeDescriptor);
}
public void setRootObject(Object rootObject) {
public void setRootObject(@Nullable Object rootObject) {
this.rootObject = (rootObject != null ? new TypedValue(rootObject) : TypedValue.NULL);
}

View File

@ -31,6 +31,7 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternUtils;
import org.springframework.lang.Nullable;
/**
* {@link FactoryBean} implementation that takes a list of location Strings
@ -60,7 +61,7 @@ public class SortedResourcesFactoryBean extends AbstractFactoryBean<Resource[]>
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}

View File

@ -627,7 +627,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
* @throws DataAccessException if there is any problem
*/
public <T> T query(
PreparedStatementCreator psc, final PreparedStatementSetter pss, final ResultSetExtractor<T> rse)
PreparedStatementCreator psc, @Nullable final PreparedStatementSetter pss, final ResultSetExtractor<T> rse)
throws DataAccessException {
Assert.notNull(rse, "ResultSetExtractor must not be null");

View File

@ -193,7 +193,7 @@ public abstract class StatementCreatorUtils {
* @see SqlTypeValue
*/
private static void setParameterValueInternal(PreparedStatement ps, int paramIndex, int sqlType,
String typeName, Integer scale, Object inValue) throws SQLException {
@Nullable String typeName, @Nullable Integer scale, Object inValue) throws SQLException {
String typeNameToUse = typeName;
int sqlTypeToUse = sqlType;

View File

@ -37,6 +37,7 @@ import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlRowSetResultSetExtractor;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.jdbc.support.rowset.SqlRowSet;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -301,7 +302,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
@Override
public int update(
String sql, SqlParameterSource paramSource, KeyHolder generatedKeyHolder, String[] keyColumnNames)
String sql, SqlParameterSource paramSource, KeyHolder generatedKeyHolder, @Nullable String[] keyColumnNames)
throws DataAccessException {
ParsedSql parsedSql = getParsedSql(sql);

View File

@ -256,7 +256,7 @@ public abstract class NamedParameterUtils {
* @return the SQL statement with substituted parameters
* @see #parseSqlStatement
*/
public static String substituteNamedParameters(ParsedSql parsedSql, SqlParameterSource paramSource) {
public static String substituteNamedParameters(ParsedSql parsedSql, @Nullable SqlParameterSource paramSource) {
String originalSql = parsedSql.getOriginalSql();
StringBuilder actualSql = new StringBuilder();
List<String> paramNames = parsedSql.getParameterNames();

View File

@ -22,6 +22,7 @@ import java.sql.Statement;
import javax.sql.DataSource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.transaction.CannotCreateTransactionException;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionSystemException;
@ -413,7 +414,7 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan
private boolean mustRestoreAutoCommit;
public void setConnectionHolder(ConnectionHolder connectionHolder, boolean newConnectionHolder) {
public void setConnectionHolder(@Nullable ConnectionHolder connectionHolder, boolean newConnectionHolder) {
super.setConnectionHolder(connectionHolder);
this.newConnectionHolder = newConnectionHolder;
}

View File

@ -22,6 +22,7 @@ import java.sql.Savepoint;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.lang.Nullable;
import org.springframework.transaction.CannotCreateTransactionException;
import org.springframework.transaction.NestedTransactionNotSupportedException;
import org.springframework.transaction.SavepointManager;
@ -56,7 +57,7 @@ public abstract class JdbcTransactionObjectSupport implements SavepointManager,
private boolean savepointAllowed = false;
public void setConnectionHolder(ConnectionHolder connectionHolder) {
public void setConnectionHolder(@Nullable ConnectionHolder connectionHolder) {
this.connectionHolder = connectionHolder;
}

View File

@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@ -164,7 +165,7 @@ public abstract class ScriptUtils {
* @param statements the list that will contain the individual statements
* @throws ScriptException if an error occurred while splitting the SQL script
*/
public static void splitSqlScript(EncodedResource resource, String script, String separator, String commentPrefix,
public static void splitSqlScript(@Nullable EncodedResource resource, String script, String separator, String commentPrefix,
String blockCommentStartDelimiter, String blockCommentEndDelimiter, List<String> statements)
throws ScriptException {

View File

@ -107,7 +107,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public List<T> execute(Object[] params, Map<?, ?> context) throws DataAccessException {
public List<T> execute(Object[] params, @Nullable Map<?, ?> context) throws DataAccessException {
validateParameters(params);
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(params), rowMapper);
@ -143,7 +143,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p1 single int parameter
* @param context the contextual information for object creation
*/
public List<T> execute(int p1, Map<?, ?> context) throws DataAccessException {
public List<T> execute(int p1, @Nullable Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@ -161,7 +161,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p2 second int parameter
* @param context the contextual information for object creation
*/
public List<T> execute(int p1, int p2, Map<?, ?> context) throws DataAccessException {
public List<T> execute(int p1, int p2, @Nullable Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1, p2}, context);
}
@ -179,7 +179,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p1 single long parameter
* @param context the contextual information for object creation
*/
public List<T> execute(long p1, Map<?, ?> context) throws DataAccessException {
public List<T> execute(long p1, @Nullable Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@ -196,7 +196,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @param p1 single String parameter
* @param context the contextual information for object creation
*/
public List<T> execute(String p1, Map<?, ?> context) throws DataAccessException {
public List<T> execute(String p1, @Nullable Map<?, ?> context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@ -220,7 +220,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public List<T> executeByNamedParam(Map<String, ?> paramMap, Map<?, ?> context) throws DataAccessException {
public List<T> executeByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?> context) throws DataAccessException {
validateNamedParameters(paramMap);
ParsedSql parsedSql = getParsedSql();
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
@ -250,7 +250,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @see org.springframework.dao.support.DataAccessUtils#singleResult
*/
@Nullable
public T findObject(Object[] params, Map<?, ?> context) throws DataAccessException {
public T findObject(Object[] params, @Nullable Map<?, ?> context) throws DataAccessException {
List<T> results = execute(params, context);
return DataAccessUtils.singleResult(results);
}
@ -266,7 +266,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given a single int parameter
* and a context.
*/
public T findObject(int p1, Map<?, ?> context) throws DataAccessException {
public T findObject(int p1, @Nullable Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
@ -281,7 +281,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given two int parameters
* and a context.
*/
public T findObject(int p1, int p2, Map<?, ?> context) throws DataAccessException {
public T findObject(int p1, int p2, @Nullable Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1, p2}, context);
}
@ -296,7 +296,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given a single long parameter
* and a context.
*/
public T findObject(long p1, Map<?, ?> context) throws DataAccessException {
public T findObject(long p1, @Nullable Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
@ -311,7 +311,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* Convenient method to find a single object given a single String parameter
* and a context.
*/
public T findObject(String p1, Map<?, ?> context) throws DataAccessException {
public T findObject(String p1, @Nullable Map<?, ?> context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
@ -333,7 +333,7 @@ public abstract class SqlQuery<T> extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public T findObjectByNamedParam(Map<String, ?> paramMap, Map<?, ?> context) throws DataAccessException {
public T findObjectByNamedParam(Map<String, ?> paramMap, @Nullable Map<?, ?> context) throws DataAccessException {
List<T> results = executeByNamedParam(paramMap, context);
return DataAccessUtils.singleResult(results);
}

View File

@ -400,7 +400,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
}
private MessageConsumer getCachedConsumer(
Destination dest, String selector, Boolean noLocal, String subscription, boolean durable) throws JMSException {
Destination dest, String selector, @Nullable Boolean noLocal, @Nullable String subscription, boolean durable) throws JMSException {
ConsumerCacheKey cacheKey = new ConsumerCacheKey(dest, selector, noLocal, subscription, durable);
MessageConsumer consumer = this.cachedConsumers.get(cacheKey);

View File

@ -134,7 +134,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
addSession(session, null);
}
public final void addSession(Session session, Connection connection) {
public final void addSession(Session session, @Nullable Connection connection) {
Assert.isTrue(!this.frozen, "Cannot add Session because JmsResourceHolder is frozen");
Assert.notNull(session, "Session must not be null");
if (!this.sessions.contains(session)) {
@ -171,7 +171,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
return getSession(sessionType, null);
}
public Session getSession(Class<? extends Session> sessionType, Connection connection) {
public Session getSession(Class<? extends Session> sessionType, @Nullable Connection connection) {
List<Session> sessions = this.sessions;
if (connection != null) {
sessions = this.sessionsPerConnection.get(connection);

View File

@ -23,6 +23,7 @@ import javax.jms.Session;
import javax.jms.TransactionRolledBackException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.lang.Nullable;
import org.springframework.transaction.CannotCreateTransactionException;
import org.springframework.transaction.InvalidIsolationLevelException;
import org.springframework.transaction.TransactionDefinition;
@ -308,7 +309,7 @@ public class JmsTransactionManager extends AbstractPlatformTransactionManager
private JmsResourceHolder resourceHolder;
public void setResourceHolder(JmsResourceHolder resourceHolder) {
public void setResourceHolder(@Nullable JmsResourceHolder resourceHolder) {
this.resourceHolder = resourceHolder;
}

Some files were not shown because too many files have changed in this diff Show More