non-matching @Transactional qualifier value will lead to IllegalStateException (SPR-6810)
This commit is contained in:
parent
6c0d934b92
commit
c5c38c6664
|
|
@ -247,7 +247,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||||
if (this.transactionManager != null || this.beanFactory == null) {
|
if (this.transactionManager != null || this.beanFactory == null) {
|
||||||
return this.transactionManager;
|
return this.transactionManager;
|
||||||
}
|
}
|
||||||
PlatformTransactionManager chosen = null;
|
|
||||||
String qualifier = txAttr.getQualifier();
|
String qualifier = txAttr.getQualifier();
|
||||||
if (StringUtils.hasLength(qualifier)) {
|
if (StringUtils.hasLength(qualifier)) {
|
||||||
if (!(this.beanFactory instanceof ConfigurableListableBeanFactory)) {
|
if (!(this.beanFactory instanceof ConfigurableListableBeanFactory)) {
|
||||||
|
|
@ -257,6 +256,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||||
ConfigurableListableBeanFactory bf = (ConfigurableListableBeanFactory) this.beanFactory;
|
ConfigurableListableBeanFactory bf = (ConfigurableListableBeanFactory) this.beanFactory;
|
||||||
Map<String, PlatformTransactionManager> tms =
|
Map<String, PlatformTransactionManager> tms =
|
||||||
BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, PlatformTransactionManager.class);
|
BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, PlatformTransactionManager.class);
|
||||||
|
PlatformTransactionManager chosen = null;
|
||||||
for (String beanName : tms.keySet()) {
|
for (String beanName : tms.keySet()) {
|
||||||
if (bf.containsBeanDefinition(beanName)) {
|
if (bf.containsBeanDefinition(beanName)) {
|
||||||
BeanDefinition bd = bf.getBeanDefinition(beanName);
|
BeanDefinition bd = bf.getBeanDefinition(beanName);
|
||||||
|
|
@ -274,9 +274,13 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (chosen != null) {
|
||||||
if (chosen != null) {
|
return chosen;
|
||||||
return chosen;
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"No matching PlatformTransactionManager bean found for qualifier '" + qualifier + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (this.transactionManagerBeanName != null) {
|
else if (this.transactionManagerBeanName != null) {
|
||||||
return this.beanFactory.getBean(this.transactionManagerBeanName, PlatformTransactionManager.class);
|
return this.beanFactory.getBean(this.transactionManagerBeanName, PlatformTransactionManager.class);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue