Restore default transaction manager by name lookup
Fix a regression introduced by 961574bd17 that prevents a proper lookup
of the default transaction manager by name as the absence of a qualifier
is represented by an empty string (passing the faulty null check).
Issue: SPR-12577
This commit is contained in:
@@ -353,16 +353,12 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
if (txAttr == null || this.beanFactory == null) {
|
||||
return getTransactionManager();
|
||||
}
|
||||
String qualifier = (txAttr.getQualifier() != null ?
|
||||
txAttr.getQualifier() : this.transactionManagerBeanName);
|
||||
String qualifier = txAttr.getQualifier();
|
||||
if (StringUtils.hasText(qualifier)) {
|
||||
PlatformTransactionManager txManager = this.transactionManagerCache.get(qualifier);
|
||||
if (txManager == null) {
|
||||
txManager = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
|
||||
this.beanFactory, PlatformTransactionManager.class, qualifier);
|
||||
this.transactionManagerCache.putIfAbsent(qualifier, txManager);
|
||||
}
|
||||
return txManager;
|
||||
return determineQualifiedTransactionManager(qualifier);
|
||||
}
|
||||
else if (StringUtils.hasText(this.transactionManagerBeanName)) {
|
||||
return determineQualifiedTransactionManager(this.transactionManagerBeanName);
|
||||
}
|
||||
else {
|
||||
PlatformTransactionManager defaultTransactionManager = getTransactionManager();
|
||||
@@ -375,6 +371,16 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
}
|
||||
}
|
||||
|
||||
private PlatformTransactionManager determineQualifiedTransactionManager(String qualifier) {
|
||||
PlatformTransactionManager txManager = this.transactionManagerCache.get(qualifier);
|
||||
if (txManager == null) {
|
||||
txManager = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
|
||||
this.beanFactory, PlatformTransactionManager.class, qualifier);
|
||||
this.transactionManagerCache.putIfAbsent(qualifier, txManager);
|
||||
}
|
||||
return txManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to return a String representation of this Method
|
||||
* for use in logging. Can be overridden in subclasses to provide a
|
||||
|
||||
Reference in New Issue
Block a user