Skip to content

@Transactional qualifier is ignored by TransactionAspectSupport if default transaction manager is set [SPR-12541] #17145

@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 961574b, 4a0ac97, cec26e9

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: dataIssues in data modules (jdbc, orm, oxm, tx)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions