Fix overridden methods nullability
Issue: SPR-15869
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -54,6 +55,7 @@ public class ChainedPersistenceExceptionTranslator implements PersistenceExcepti
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
for (PersistenceExceptionTranslator pet : this.delegates) {
|
||||
DataAccessException translatedDex = pet.translateExceptionIfPossible(ex);
|
||||
|
||||
@@ -67,6 +67,7 @@ public abstract class DataAccessUtils {
|
||||
* @throws EmptyResultDataAccessException if no element at all
|
||||
* has been found in the given Collection
|
||||
*/
|
||||
@Nullable
|
||||
public static <T> T requiredSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException {
|
||||
int size = (results != null ? results.size() : 0);
|
||||
if (size == 0) {
|
||||
|
||||
@@ -204,6 +204,7 @@ public class CciTemplate implements CciOperations {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T execute(ConnectionCallback<T> action) throws DataAccessException {
|
||||
Assert.notNull(action, "Callback object must not be null");
|
||||
ConnectionFactory connectionFactory = obtainConnectionFactory();
|
||||
@@ -226,6 +227,7 @@ public class CciTemplate implements CciOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T execute(final InteractionCallback<T> action) throws DataAccessException {
|
||||
Assert.notNull(action, "Callback object must not be null");
|
||||
return execute((ConnectionCallback<T>) (connection, connectionFactory) -> {
|
||||
@@ -240,6 +242,7 @@ public class CciTemplate implements CciOperations {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Record execute(InteractionSpec spec, Record inputRecord) throws DataAccessException {
|
||||
return doExecute(spec, inputRecord, null, new SimpleRecordExtractor());
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ public class LocalConnectionFactoryBean implements FactoryBean<Object>, Initiali
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getObject() {
|
||||
return this.connectionFactory;
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ public class ResourceAdapterFactoryBean implements FactoryBean<ResourceAdapter>,
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceAdapter getObject() {
|
||||
return this.resourceAdapter;
|
||||
}
|
||||
|
||||
@@ -130,11 +130,13 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttribute findTransactionAttribute(Method method) {
|
||||
return determineTransactionAttribute(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttribute findTransactionAttribute(Class<?> clazz) {
|
||||
return determineTransactionAttribute(clazz);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.lang.reflect.AnnotatedElement;
|
||||
import javax.ejb.ApplicationException;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
|
||||
import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
|
||||
@@ -35,6 +36,7 @@ import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
public class Ejb3TransactionAnnotationParser implements TransactionAnnotationParser, Serializable {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
|
||||
javax.ejb.TransactionAttribute ann = ae.getAnnotation(javax.ejb.TransactionAttribute.class);
|
||||
if (ann != null) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.interceptor.NoRollbackRuleAttribute;
|
||||
import org.springframework.transaction.interceptor.RollbackRuleAttribute;
|
||||
import org.springframework.transaction.interceptor.RuleBasedTransactionAttribute;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
public class JtaTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
|
||||
AnnotationAttributes attributes =
|
||||
AnnotatedElementUtils.getMergedAnnotationAttributes(ae, javax.transaction.Transactional.class);
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.interceptor.NoRollbackRuleAttribute;
|
||||
import org.springframework.transaction.interceptor.RollbackRuleAttribute;
|
||||
import org.springframework.transaction.interceptor.RuleBasedTransactionAttribute;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
public class SpringTransactionAnnotationParser implements TransactionAnnotationParser, Serializable {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute parseTransactionAnnotation(AnnotatedElement ae) {
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
|
||||
ae, Transactional.class, false, false);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.event.TransactionalEventListenerFactory;
|
||||
import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor;
|
||||
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
@@ -56,6 +57,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
* with the container as necessary.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
registerTransactionalEventListenerFactory(parserContext);
|
||||
String mode = element.getAttribute("mode");
|
||||
|
||||
@@ -70,6 +70,7 @@ public class JtaTransactionManagerFactoryBean implements FactoryBean<JtaTransact
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JtaTransactionManager getObject() {
|
||||
return this.transactionManager;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
|
||||
* is not transactional
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute getTransactionAttribute(Method method, @Nullable Class<?> targetClass) {
|
||||
if (method.getDeclaringClass() == Object.class) {
|
||||
return null;
|
||||
|
||||
@@ -39,6 +39,7 @@ public class BeanFactoryTransactionAttributeSourceAdvisor extends AbstractBeanFa
|
||||
|
||||
private final TransactionAttributeSourcePointcut pointcut = new TransactionAttributeSourcePointcut() {
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttributeSource getTransactionAttributeSource() {
|
||||
return transactionAttributeSource;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.transaction.interceptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.support.DelegatingTransactionDefinition;
|
||||
|
||||
/**
|
||||
@@ -47,6 +48,7 @@ public abstract class DelegatingTransactionAttribute extends DelegatingTransacti
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getQualifier() {
|
||||
return this.targetAttribute.getQualifier();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class MatchAlwaysTransactionAttributeSource implements TransactionAttribu
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute getTransactionAttribute(Method method, @Nullable Class<?> targetClass) {
|
||||
return (ClassUtils.isUserLevelMethod(method) ? this.transactionAttribute : null);
|
||||
}
|
||||
|
||||
@@ -207,6 +207,7 @@ public class MethodMapTransactionAttributeSource
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute getTransactionAttribute(Method method, @Nullable Class<?> targetClass) {
|
||||
if (this.eagerlyInitialized) {
|
||||
return this.transactionAttributeMap.get(method);
|
||||
|
||||
@@ -99,6 +99,7 @@ public class NameMatchTransactionAttributeSource implements TransactionAttribute
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TransactionAttribute getTransactionAttribute(Method method, @Nullable Class<?> targetClass) {
|
||||
if (!ClassUtils.isUserLevelMethod(method)) {
|
||||
return null;
|
||||
|
||||
@@ -448,6 +448,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
if (txAttr != null && txAttr.getName() == null) {
|
||||
txAttr = new DelegatingTransactionAttribute(txAttr) {
|
||||
@Override
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return joinpointIdentification;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class TransactionAttributeSourceAdvisor extends AbstractPointcutAdvisor {
|
||||
|
||||
private final TransactionAttributeSourcePointcut pointcut = new TransactionAttributeSourcePointcut() {
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionAttributeSource getTransactionAttributeSource() {
|
||||
return (transactionInterceptor != null ? transactionInterceptor.getTransactionAttributeSource() : null);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected UserTransaction retrieveUserTransaction() throws TransactionSystemException {
|
||||
Object helper = loadWebLogicTransactionHelper();
|
||||
try {
|
||||
@@ -131,6 +132,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected TransactionManager retrieveTransactionManager() throws TransactionSystemException {
|
||||
Object helper = loadWebLogicTransactionHelper();
|
||||
try {
|
||||
|
||||
@@ -229,6 +229,7 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T execute(@Nullable TransactionDefinition definition, TransactionCallback<T> callback)
|
||||
throws TransactionException {
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.transaction.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -67,6 +68,7 @@ public abstract class DelegatingTransactionDefinition implements TransactionDefi
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.targetDefinition.getName();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.beans.factory.config.Scope;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -60,6 +61,7 @@ public class SimpleTransactionScope implements Scope {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object remove(String name) {
|
||||
ScopedObjectsHolder scopedObjects = (ScopedObjectsHolder) TransactionSynchronizationManager.getResource(this);
|
||||
if (scopedObjects != null) {
|
||||
@@ -80,11 +82,13 @@ public class SimpleTransactionScope implements Scope {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getConversationId() {
|
||||
return TransactionSynchronizationManager.getCurrentTransactionName();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.transaction.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,7 @@ import org.springframework.transaction.TransactionStatus;
|
||||
public abstract class TransactionCallbackWithoutResult implements TransactionCallback<Object> {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final Object doInTransaction(TransactionStatus status) {
|
||||
doInTransactionWithoutResult(status);
|
||||
return null;
|
||||
|
||||
@@ -126,6 +126,7 @@ public class TransactionTemplate extends DefaultTransactionDefinition
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T execute(TransactionCallback<T> action) throws TransactionException {
|
||||
Assert.state(this.transactionManager != null, "No PlatformTransactionManager set");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user