Fix overridden methods nullability

Issue: SPR-15869
This commit is contained in:
Sebastien Deleuze
2017-08-17 14:30:14 +02:00
parent 6b6c1d3e53
commit 73cf07e9a4
488 changed files with 1016 additions and 34 deletions

View File

@@ -157,7 +157,8 @@ public interface Cache {
/**
* Return the actual value in the cache.
*/
@Nullable Object get();
@Nullable
Object get();
}

View File

@@ -106,11 +106,13 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati
@Override
@Nullable
protected Collection<CacheOperation> findCacheOperations(final Class<?> clazz) {
return determineCacheOperations(parser -> parser.parseCacheAnnotations(clazz));
}
@Override
@Nullable
protected Collection<CacheOperation> findCacheOperations(final Method method) {
return determineCacheOperations(parser -> parser.parseCacheAnnotations(method));
}

View File

@@ -20,6 +20,7 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.lang.Nullable;
/**
* An implementation of {@link CachingConfigurer} with empty methods allowing
@@ -32,21 +33,25 @@ import org.springframework.cache.interceptor.KeyGenerator;
public class CachingConfigurerSupport implements CachingConfigurer {
@Override
@Nullable
public CacheManager cacheManager() {
return null;
}
@Override
@Nullable
public KeyGenerator keyGenerator() {
return null;
}
@Override
@Nullable
public CacheResolver cacheResolver() {
return null;
}
@Override
@Nullable
public CacheErrorHandler errorHandler() {
return null;
}

View File

@@ -48,12 +48,14 @@ import org.springframework.util.StringUtils;
public class SpringCacheAnnotationParser implements CacheAnnotationParser, Serializable {
@Override
@Nullable
public Collection<CacheOperation> parseCacheAnnotations(Class<?> type) {
DefaultCacheConfig defaultConfig = getDefaultCacheConfig(type);
return parseCacheAnnotations(defaultConfig, type);
}
@Override
@Nullable
public Collection<CacheOperation> parseCacheAnnotations(Method method) {
DefaultCacheConfig defaultConfig = getDefaultCacheConfig(method.getDeclaringClass());
return parseCacheAnnotations(defaultConfig, method);

View File

@@ -92,6 +92,7 @@ public class ConcurrentMapCacheFactoryBean
@Override
@Nullable
public ConcurrentMapCache getObject() {
return this.cache;
}

View File

@@ -162,6 +162,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA
}
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.cacheMap.get(name);
if (cache == null && this.dynamic) {

View File

@@ -75,6 +75,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
* register an AutoProxyCreator} with the container as necessary.
*/
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
String mode = element.getAttribute("mode");
if ("aspectj".equals(mode)) {

View File

@@ -83,6 +83,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
* is not cacheable
*/
@Override
@Nullable
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
if (method.getDeclaringClass() == Object.class) {
return null;

View File

@@ -36,6 +36,7 @@ public class BeanFactoryCacheOperationSourceAdvisor extends AbstractBeanFactoryP
private final CacheOperationSourcePointcut pointcut = new CacheOperationSourcePointcut() {
@Override
@Nullable
protected CacheOperationSource getCacheOperationSource() {
return cacheOperationSource;
}

View File

@@ -22,6 +22,7 @@ import java.util.Set;
import org.springframework.context.expression.MethodBasedEvaluationContext;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.lang.Nullable;
/**
* Cache specific evaluation context that adds a method parameters as SpEL
@@ -69,6 +70,7 @@ class CacheEvaluationContext extends MethodBasedEvaluationContext {
* Load the param information only when needed.
*/
@Override
@Nullable
public Object lookupVariable(String name) {
if (this.unavailableVariables.contains(name)) {
throw new VariableNotAvailableException(name);

View File

@@ -55,6 +55,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
}
@Override
@Nullable
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
Collection<CacheOperation> ops = null;

View File

@@ -75,6 +75,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
}
@Override
@Nullable
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
// look for direct name match
String methodName = method.getName();

View File

@@ -85,6 +85,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
// Lazy cache initialization on access
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.cacheMap.get(name);
if (cache != null) {

View File

@@ -27,6 +27,7 @@ import java.util.Set;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;
/**
* Composite {@link CacheManager} implementation that iterates over
@@ -98,6 +99,7 @@ public class CompositeCacheManager implements CacheManager, InitializingBean {
@Override
@Nullable
public Cache getCache(String name) {
for (CacheManager cacheManager : this.cacheManagers) {
Cache cache = cacheManager.getCache(name);

View File

@@ -58,16 +58,19 @@ public class NoOpCache implements Cache {
}
@Override
@Nullable
public ValueWrapper get(Object key) {
return null;
}
@Override
@Nullable
public <T> T get(Object key, @Nullable Class<T> type) {
return null;
}
@Override
@Nullable
public <T> T get(Object key, Callable<T> valueLoader) {
try {
return valueLoader.call();

View File

@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentMap;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.lang.Nullable;
/**
* A basic, no operation {@link CacheManager} implementation suitable
@@ -50,6 +51,7 @@ public class NoOpCacheManager implements CacheManager {
* Additionally, the request cache will be remembered by the manager for consistency.
*/
@Override
@Nullable
public Cache getCache(String name) {
Cache cache = this.caches.get(name);
if (cache == null) {

View File

@@ -45,6 +45,7 @@ public class SimpleValueWrapper implements ValueWrapper {
* Simply returns the value as given at construction time.
*/
@Override
@Nullable
public Object get() {
return this.value;
}

View File

@@ -26,6 +26,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
/**
* Parser for the &lt;context:annotation-config/&gt; element.
@@ -39,6 +40,7 @@ import org.springframework.beans.factory.xml.ParserContext;
public class AnnotationConfigBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);

View File

@@ -173,6 +173,7 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
/**
* Return the BeanDefinitionRegistry that this scanner operates on.
*/
@Override
public final BeanDefinitionRegistry getRegistry() {
return this.registry;
}

View File

@@ -79,6 +79,7 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
String basePackage = element.getAttribute(BASE_PACKAGE_ATTRIBUTE);
basePackage = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(basePackage);

View File

@@ -714,6 +714,7 @@ class ConfigurationClassParser {
}
@Override
@Nullable
public AnnotationMetadata getImportingClassFor(String importedClass) {
List<AnnotationMetadata> list = this.imports.get(importedClass);
return (!CollectionUtils.isEmpty(list) ? list.get(list.size() - 1) : null);

View File

@@ -47,6 +47,7 @@ import org.springframework.util.Assert;
public class ContextAnnotationAutowireCandidateResolver extends QualifierAnnotationAutowireCandidateResolver {
@Override
@Nullable
public Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, @Nullable String beanName) {
return (isLazy(descriptor) ? buildLazyResolutionProxy(descriptor, beanName) : null);
}

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.MethodMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -68,6 +69,7 @@ public class ScannedGenericBeanDefinition extends GenericBeanDefinition implemen
}
@Override
@Nullable
public MethodMetadata getFactoryMethodMetadata() {
return null;
}

View File

@@ -21,6 +21,7 @@ import java.util.Arrays;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -60,6 +61,7 @@ public class MethodBasedEvaluationContext extends StandardEvaluationContext {
@Override
@Nullable
public Object lookupVariable(String name) {
Object variable = super.lookupVariable(name);
if (variable != null) {

View File

@@ -132,6 +132,7 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
@Override
@Nullable
public Object evaluate(@Nullable String value, BeanExpressionContext evalContext) throws BeansException {
if (!StringUtils.hasLength(value)) {
return value;

View File

@@ -1137,6 +1137,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
@Override
@Nullable
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
assertBeanFactoryActive();
return getBeanFactory().getType(name);
@@ -1214,6 +1215,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
@@ -1227,6 +1229,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
//---------------------------------------------------------------------
@Override
@Nullable
public BeanFactory getParentBeanFactory() {
return getParent();
}

View File

@@ -31,6 +31,7 @@ import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.lang.Nullable;
import org.springframework.util.StringValueResolver;
/**
@@ -74,6 +75,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor {
@Override
@Nullable
public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException {
AccessControlContext acc = null;

View File

@@ -87,6 +87,7 @@ public class ConversionServiceFactoryBean implements FactoryBean<ConversionServi
// implementing FactoryBean
@Override
@Nullable
public ConversionService getObject() {
return this.conversionService;
}

View File

@@ -245,6 +245,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
}
@Override
@Nullable
public ClassLoader getClassLoader() {
if (this.resourceLoader != null && !this.customClassLoader) {
return this.resourceLoader.getClassLoader();

View File

@@ -132,6 +132,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
this.propertySources.addLast(
new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
@Override
@Nullable
public String getProperty(String key) {
return this.source.getProperty(key);
}

View File

@@ -201,6 +201,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
* using a cached MessageFormat instance per message code.
*/
@Override
@Nullable
protected MessageFormat resolveCode(String code, Locale locale) {
if (getCacheMillis() < 0) {
PropertiesHolder propHolder = getMergedProperties(locale);

View File

@@ -145,6 +145,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
* using a cached MessageFormat instance per message code.
*/
@Override
@Nullable
protected MessageFormat resolveCode(String code, Locale locale) {
Set<String> basenames = getBasenameSet();
for (String basename : basenames) {

View File

@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.config.Scope;
import org.springframework.core.NamedThreadLocal;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -78,6 +79,7 @@ public class SimpleThreadScope implements Scope {
}
@Override
@Nullable
public Object remove(String name) {
Map<String, Object> scope = this.threadScope.get();
return scope.remove(name);
@@ -90,6 +92,7 @@ public class SimpleThreadScope implements Scope {
}
@Override
@Nullable
public Object resolveContextualObject(String key) {
return null;
}

View File

@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -47,6 +48,7 @@ public class StaticMessageSource extends AbstractMessageSource {
}
@Override
@Nullable
protected MessageFormat resolveCode(String code, Locale locale) {
String key = code + '_' + locale.toString();
String msg = this.messages.get(key);

View File

@@ -95,6 +95,7 @@ public abstract class AbstractRemoteSlsbInvokerInterceptor extends AbstractSlsbI
* @see #refreshAndRetry
*/
@Override
@Nullable
public Object invokeInContext(MethodInvocation invocation) throws Throwable {
try {
return doInvoke(invocation);

View File

@@ -62,6 +62,7 @@ public class LocalSlsbInvokerInterceptor extends AbstractSlsbInvokerInterceptor
* for example to hold a single shared EJB instance.
*/
@Override
@Nullable
public Object invokeInContext(MethodInvocation invocation) throws Throwable {
Object ejb = null;
try {

View File

@@ -98,6 +98,7 @@ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInter
@Override
@Nullable
public Object getObject() {
return this.proxy;
}

View File

@@ -93,6 +93,7 @@ public class SimpleRemoteSlsbInvokerInterceptor extends AbstractRemoteSlsbInvoke
* for example to hold a single shared EJB component instance.
*/
@Override
@Nullable
protected Object doInvoke(MethodInvocation invocation) throws Throwable {
Object ejb = null;
try {

View File

@@ -112,6 +112,7 @@ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSl
@Override
@Nullable
public Object getObject() {
return this.proxy;
}

View File

@@ -47,6 +47,7 @@ public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
}
@Override
@Nullable
public DateTimeFormatter getObject() {
return this.dateTimeFormatter;
}

View File

@@ -47,6 +47,7 @@ public class DateTimeFormatterFactoryBean extends DateTimeFormatterFactory
}
@Override
@Nullable
public DateTimeFormatter getObject() {
return this.dateTimeFormatter;
}

View File

@@ -189,6 +189,7 @@ public class FormattingConversionService extends GenericConversionService
}
@Override
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
String text = (String) source;
if (!StringUtils.hasText(text)) {
@@ -247,6 +248,7 @@ public class FormattingConversionService extends GenericConversionService
@Override
@SuppressWarnings("unchecked")
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
Annotation ann = sourceType.getAnnotation(this.annotationType);
if (ann == null) {
@@ -301,6 +303,7 @@ public class FormattingConversionService extends GenericConversionService
@Override
@SuppressWarnings("unchecked")
@Nullable
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
Annotation ann = targetType.getAnnotation(this.annotationType);
if (ann == null) {

View File

@@ -167,6 +167,7 @@ public class FormattingConversionServiceFactoryBean
@Override
@Nullable
public FormattingConversionService getObject() {
return this.conversionService;
}

View File

@@ -99,6 +99,7 @@ public class MBeanProxyFactoryBean extends MBeanClientInterceptor
@Override
@Nullable
public Object getObject() {
return this.mbeanProxy;
}

View File

@@ -1102,6 +1102,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
}
@Override
@Nullable
public Object getTarget() {
try {
return super.getTarget();

View File

@@ -63,6 +63,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedResource getManagedResource(Class<?> beanClass) throws InvalidMetadataException {
ManagedResource ann = AnnotationUtils.findAnnotation(beanClass, ManagedResource.class);
if (ann == null) {
@@ -79,6 +80,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
}
@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException {
ManagedAttribute ann = AnnotationUtils.findAnnotation(method, ManagedAttribute.class);
if (ann == null) {
@@ -93,12 +95,14 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
}
@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException {
ManagedMetric ann = AnnotationUtils.findAnnotation(method, ManagedMetric.class);
return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedMetric.class);
}
@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException {
ManagedOperation ann = AnnotationUtils.findAnnotation(method, ManagedOperation.class);
return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedOperation.class);

View File

@@ -205,6 +205,7 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport
@Override
@Nullable
public JMXConnectorServer getObject() {
return this.connectorServer;
}

View File

@@ -157,6 +157,7 @@ public class MBeanServerConnectionFactoryBean
@Override
@Nullable
public MBeanServerConnection getObject() {
return this.connection;
}

View File

@@ -185,6 +185,7 @@ public class MBeanServerFactoryBean implements FactoryBean<MBeanServer>, Initial
@Override
@Nullable
public MBeanServer getObject() {
return this.server;
}

View File

@@ -84,6 +84,7 @@ public class WebSphereMBeanServerFactoryBean implements FactoryBean<MBeanServer>
@Override
@Nullable
public MBeanServer getObject() {
return this.mbeanServer;
}

View File

@@ -266,6 +266,7 @@ public class JndiObjectFactoryBean extends JndiObjectLocator
* Return the singleton JNDI object.
*/
@Override
@Nullable
public Object getObject() {
return this.jndiObject;
}

View File

@@ -109,6 +109,7 @@ public class JndiObjectTargetSource extends JndiObjectLocator implements TargetS
@Override
@Nullable
public Class<?> getTargetClass() {
if (this.cachedObject != null) {
return this.cachedObject.getClass();
@@ -127,6 +128,7 @@ public class JndiObjectTargetSource extends JndiObjectLocator implements TargetS
}
@Override
@Nullable
public Object getTarget() {
try {
if (this.lookupOnStartup || !this.cache) {

View File

@@ -19,6 +19,7 @@ package org.springframework.jndi;
import javax.naming.NamingException;
import org.springframework.core.env.PropertySource;
import org.springframework.lang.Nullable;
/**
* {@link PropertySource} implementation that reads properties from an underlying Spring
@@ -77,6 +78,7 @@ public class JndiPropertySource extends PropertySource<JndiLocatorDelegate> {
* {@code null} and issues a DEBUG-level log statement with the exception message.
*/
@Override
@Nullable
public Object getProperty(String name) {
if (getSource().isResourceRef() && name.indexOf(':') != -1) {
// We're in resource-ref (prefixing with "java:comp/env") mode. Let's not bother

View File

@@ -187,6 +187,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
}
@Override
@Nullable
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
try {
return doGetType(name);

View File

@@ -19,6 +19,7 @@ package org.springframework.remoting.rmi;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import org.springframework.lang.Nullable;
import org.springframework.remoting.support.RemoteInvocation;
import org.springframework.util.Assert;
@@ -58,6 +59,7 @@ class RmiInvocationWrapper implements RmiInvocationHandler {
* @see RmiBasedExporter#getServiceInterface()
*/
@Override
@Nullable
public String getTargetInterfaceName() {
Class<?> ifc = this.rmiExporter.getServiceInterface();
return (ifc != null ? ifc.getName() : null);
@@ -68,6 +70,7 @@ class RmiInvocationWrapper implements RmiInvocationHandler {
* @see RmiBasedExporter#invoke(org.springframework.remoting.support.RemoteInvocation, Object)
*/
@Override
@Nullable
public Object invoke(RemoteInvocation invocation)
throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {

View File

@@ -76,6 +76,7 @@ public class AnnotationAsyncExecutionInterceptor extends AsyncExecutionIntercept
* @see #determineAsyncExecutor(Method)
*/
@Override
@Nullable
protected String getExecutorQualifier(Method method) {
// Maintainer's note: changes made here should also be made in
// AnnotationAsyncExecutionAspect#getExecutorQualifier

View File

@@ -18,6 +18,7 @@ package org.springframework.scheduling.annotation;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AdviceModeImportSelector;
import org.springframework.lang.Nullable;
/**
* Selects which implementation of {@link AbstractAsyncConfiguration} should be used based
@@ -39,6 +40,7 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector<EnableA
* {@code PROXY} and {@code ASPECTJ} values of {@link EnableAsync#mode()}, respectively
*/
@Override
@Nullable
public String[] selectImports(AdviceMode adviceMode) {
switch (adviceMode) {
case PROXY:

View File

@@ -19,6 +19,7 @@ package org.springframework.scheduling.annotation;
import java.util.concurrent.Executor;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.lang.Nullable;
/**
* A convenience {@link AsyncConfigurer} that implements all methods
@@ -36,6 +37,7 @@ public class AsyncConfigurerSupport implements AsyncConfigurer {
}
@Override
@Nullable
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return null;
}

View File

@@ -169,6 +169,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
@Override
@Nullable
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
try {
if (this.enterpriseConcurrentScheduler) {

View File

@@ -134,6 +134,7 @@ public class ForkJoinPoolFactoryBean implements FactoryBean<ForkJoinPool>, Initi
@Override
@Nullable
public ForkJoinPool getObject() {
return this.forkJoinPool;
}

View File

@@ -232,6 +232,7 @@ public class ScheduledExecutorFactoryBean extends ExecutorConfigurationSupport
@Override
@Nullable
public ScheduledExecutorService getObject() {
return this.exposedExecutor;
}

View File

@@ -192,6 +192,7 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport
@Override
@Nullable
public ExecutorService getObject() {
return this.exposedExecutor;
}

View File

@@ -284,6 +284,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
// TaskScheduler implementation
@Override
@Nullable
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
ScheduledExecutorService executor = getScheduledExecutor();
try {

View File

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;
/**
@@ -46,6 +47,7 @@ public class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParse
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
Object source = parserContext.extractSource(element);

View File

@@ -144,6 +144,7 @@ public class TaskExecutorFactoryBean implements
@Override
@Nullable
public TaskExecutor getObject() {
return this.target;
}

View File

@@ -72,16 +72,19 @@ public class SimpleTriggerContext implements TriggerContext {
@Override
@Nullable
public Date lastScheduledExecutionTime() {
return this.lastScheduledExecutionTime;
}
@Override
@Nullable
public Date lastActualExecutionTime() {
return this.lastActualExecutionTime;
}
@Override
@Nullable
public Date lastCompletionTime() {
return this.lastCompletionTime;
}

View File

@@ -122,6 +122,7 @@ public class BshScriptFactory implements ScriptFactory, BeanClassLoaderAware {
* @see BshScriptUtils#createBshObject(String, Class[], ClassLoader)
*/
@Override
@Nullable
public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>... actualInterfaces)
throws IOException, ScriptCompilationException {
@@ -180,6 +181,7 @@ public class BshScriptFactory implements ScriptFactory, BeanClassLoaderAware {
}
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
throws IOException, ScriptCompilationException {

View File

@@ -104,6 +104,7 @@ class ScriptBeanDefinitionParser extends AbstractBeanDefinitionParser {
*/
@Override
@SuppressWarnings("deprecation")
@Nullable
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
// Engine attribute only supported for <lang:std>
String engine = element.getAttribute(ENGINE_ATTRIBUTE);

View File

@@ -195,6 +195,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
* @return {@code null} always
*/
@Override
@Nullable
public Class<?>[] getScriptInterfaces() {
return null;
}
@@ -214,6 +215,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
* @see groovy.lang.GroovyClassLoader
*/
@Override
@Nullable
public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>... actualInterfaces)
throws IOException, ScriptCompilationException {
@@ -257,6 +259,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
}
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
throws IOException, ScriptCompilationException {

View File

@@ -128,6 +128,7 @@ public class ResourceScriptSource implements ScriptSource {
}
@Override
@Nullable
public String suggestedClassName() {
String filename = getResource().getFilename();
return (filename != null ? StringUtils.stripFilenameExtension(filename) : null);

View File

@@ -244,6 +244,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
@Override
@Nullable
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
// We only apply special treatment to ScriptFactory implementations here.
if (!ScriptFactory.class.isAssignableFrom(beanClass)) {

View File

@@ -131,11 +131,13 @@ public class StandardScriptEvaluator implements ScriptEvaluator, BeanClassLoader
@Override
@Nullable
public Object evaluate(ScriptSource script) {
return evaluate(script, null);
}
@Override
@Nullable
public Object evaluate(ScriptSource script, @Nullable Map<String, Object> argumentBindings) {
ScriptEngine engine = getScriptEngine(script);
try {

View File

@@ -139,6 +139,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
* Load and parse the script via JSR-223's ScriptEngine.
*/
@Override
@Nullable
public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>... actualInterfaces)
throws IOException, ScriptCompilationException {
@@ -259,6 +260,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
}
@Override
@Nullable
public Class<?> getScriptedObjectType(ScriptSource scriptSource)
throws IOException, ScriptCompilationException {

View File

@@ -82,6 +82,7 @@ public class StaticScriptSource implements ScriptSource {
}
@Override
@Nullable
public String suggestedClassName() {
return this.className;
}

View File

@@ -51,6 +51,7 @@ public class DelegatingThemeSource implements HierarchicalThemeSource {
@Override
@Nullable
public Theme getTheme(String themeName) {
if (this.parentThemeSource != null) {
return this.parentThemeSource.getTheme(themeName);

View File

@@ -136,6 +136,7 @@ public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanC
* @see #createMessageSource
*/
@Override
@Nullable
public Theme getTheme(String themeName) {
Theme theme = this.themeCache.get(themeName);
if (theme == null) {

View File

@@ -168,6 +168,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
}
@Override
@Nullable
public ObjectError getGlobalError() {
for (ObjectError objectError : this.errors) {
if (!(objectError instanceof FieldError)) {
@@ -189,6 +190,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
}
@Override
@Nullable
public FieldError getFieldError() {
for (ObjectError objectError : this.errors) {
if (objectError instanceof FieldError) {
@@ -211,6 +213,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
}
@Override
@Nullable
public FieldError getFieldError(String field) {
String fixedField = fixedField(field);
for (ObjectError objectError : this.errors) {
@@ -225,6 +228,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
}
@Override
@Nullable
public Object getFieldValue(String field) {
FieldError fieldError = getFieldError(field);
// Use rejected value in case of error, current bean property value else.
@@ -244,6 +248,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
* @see #getActualFieldValue
*/
@Override
@Nullable
public Class<?> getFieldType(@Nullable String field) {
Object value = getActualFieldValue(fixedField(field));
if (value != null) {
@@ -280,6 +285,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
}
@Override
@Nullable
public Object getRawFieldValue(String field) {
return getActualFieldValue(fixedField(field));
}
@@ -290,6 +296,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
* editor lookup facility, if available.
*/
@Override
@Nullable
public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) {
PropertyEditorRegistry editorRegistry = getPropertyEditorRegistry();
if (editorRegistry != null) {
@@ -308,6 +315,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
* This implementation returns {@code null}.
*/
@Override
@Nullable
public PropertyEditorRegistry getPropertyEditorRegistry() {
return null;
}
@@ -363,6 +371,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
* Return the wrapped target object.
*/
@Override
@Nullable
public abstract Object getTarget();
/**

View File

@@ -162,6 +162,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
}
@Override
@Nullable
public ObjectError getGlobalError() {
List<ObjectError> globalErrors = getGlobalErrors();
return (!globalErrors.isEmpty() ? globalErrors.get(0) : null);
@@ -178,6 +179,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
}
@Override
@Nullable
public FieldError getFieldError() {
List<FieldError> fieldErrors = getFieldErrors();
return (!fieldErrors.isEmpty() ? fieldErrors.get(0) : null);
@@ -207,13 +209,14 @@ public abstract class AbstractErrors implements Errors, Serializable {
}
@Override
@Nullable
public FieldError getFieldError(String field) {
List<FieldError> fieldErrors = getFieldErrors(field);
return (!fieldErrors.isEmpty() ? fieldErrors.get(0) : null);
}
@Override
@Nullable
public Class<?> getFieldType(String field) {
Object value = getFieldValue(field);
return (value != null ? value.getClass() : null);

View File

@@ -88,6 +88,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
* @see #getPropertyAccessor()
*/
@Override
@Nullable
public Class<?> getFieldType(@Nullable String field) {
return getPropertyAccessor().getPropertyType(fixedField(field));
}
@@ -97,6 +98,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
* @see #getPropertyAccessor()
*/
@Override
@Nullable
protected Object getActualFieldValue(String field) {
return getPropertyAccessor().getPropertyValue(field);
}
@@ -150,6 +152,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
* if applicable.
*/
@Override
@Nullable
public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) {
Class<?> valueTypeForLookup = valueType;
if (valueTypeForLookup == null) {

View File

@@ -171,6 +171,7 @@ public class BindException extends Exception implements BindingResult {
}
@Override
@Nullable
public ObjectError getGlobalError() {
return this.bindingResult.getGlobalError();
}
@@ -191,6 +192,7 @@ public class BindException extends Exception implements BindingResult {
}
@Override
@Nullable
public FieldError getFieldError() {
return this.bindingResult.getFieldError();
}
@@ -211,16 +213,19 @@ public class BindException extends Exception implements BindingResult {
}
@Override
@Nullable
public FieldError getFieldError(String field) {
return this.bindingResult.getFieldError(field);
}
@Override
@Nullable
public Object getFieldValue(String field) {
return this.bindingResult.getFieldValue(field);
}
@Override
@Nullable
public Class<?> getFieldType(String field) {
return this.bindingResult.getFieldType(field);
}
@@ -236,6 +241,7 @@ public class BindException extends Exception implements BindingResult {
}
@Override
@Nullable
public Object getRawFieldValue(String field) {
return this.bindingResult.getRawFieldValue(field);
}

View File

@@ -672,16 +672,19 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
}
@Override
@Nullable
public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) {
return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath);
}
@Override
@Nullable
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType) throws TypeMismatchException {
return getTypeConverter().convertIfNecessary(value, requiredType);
}
@Override
@Nullable
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType,
@Nullable MethodParameter methodParam) throws TypeMismatchException {
@@ -689,6 +692,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
}
@Override
@Nullable
public <T> T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType, @Nullable Field field)
throws TypeMismatchException {

View File

@@ -19,6 +19,7 @@ package org.springframework.validation;
import java.io.Serializable;
import java.util.Map;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -61,6 +62,7 @@ public class MapBindingResult extends AbstractBindingResult implements Serializa
}
@Override
@Nullable
protected Object getActualFieldValue(String field) {
return this.target.get(field);
}

View File

@@ -367,6 +367,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
}
@Override
@Nullable
public Object[] getArguments() {
return null;
}