-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Donnchadh O Donnabhain opened SPR-12541 and commented
Status Quo
#16570 introduced caching of the default PlatformTransactionManager
in TransactionAspectSupport
.
Specifically, the transactionManager
instance field is now set within determineTransactionManager()
. In subsequent invocations of determineTransactionManager()
, the following if-logic at the beginning of the method results in the cached default transaction manager being returned instead of the transaction manager with the specified qualifier.
if (this.transactionManager != null || this.beanFactory == null || txAttr == null) {
return this.transactionManager;
}
Note, however, that the default transaction manager may have been set in Java Config due to the use of TransactionManagementConfigurer
, or it may have been set in XML config via TransactionProxyFactoryBean.setTransactionManager()
. Therefore, the behavior reported in this issue is not limited to caching of the default transaction manager in determineTransactionManager()
. Rather, the behavior can be experienced any time the transactionManager
field in TransactionAspectSupport
has been set.
Steps to Reproduce
Given
@Transactional
public void doFoo() {
// ...
}
@Transactional("transactionManager2")
public void doBar() {
// ...
}
and
service.doFoo();
service.doBar();
... the default transaction manager will be used for invocations of service.doBar()
rather than transactionManager2
.
Further Resources
See discussion on GitHub.
Affects: 4.1 GA
Issue Links:
- Potential null-pointer in TransactionAspectSupport.determineTransactionManager() [SPR-7153] #11812 Potential null-pointer in TransactionAspectSupport.determineTransactionManager() ("depends on")
- support for multiple transaction managers with @Transactional / <tx:annotation-driven> [SPR-3955] #8635 support for multiple transaction managers with
@Transactional
/ tx:annotation-driven ("depends on") - Reduce PlatformTransactionManager lookups in TransactionAspectSupport [SPR-11954] #16570 Reduce PlatformTransactionManager lookups in TransactionAspectSupport ("depends on")
- AnnotationTransactionAspect retains reference to JpaTransactionManager from closed context [SPR-12518] #17123 AnnotationTransactionAspect retains reference to JpaTransactionManager from closed context
- Wrong TransactionManager selected when mixing @Transactional with and w/o qualifier [SPR-12606] #17207 Wrong TransactionManager selected when mixing
@Transactional
with and w/o qualifier - Regression in TransactionAspectSupport.determineTransactionManager(…) [SPR-12577] #17178 Regression in TransactionAspectSupport.determineTransactionManager(…)
- Transaction manager bean in TransactionInterceptor retained after JUnit test class completes [SPR-14511] #19080 Transaction manager bean in TransactionInterceptor retained after JUnit test class completes
Referenced from: commits 961574b, 4a0ac97, cec26e9
0 votes, 5 watchers