Skip to content

Validation of existing transactions with transaction synchronization turned off not working (?) [SPR-15016] #19583

@spring-projects-issues

Description

@spring-projects-issues

Vojtech Toman opened SPR-15016 and commented

In out project, we have our own transaction manager implementation. In the test suite, we have a test that checks the various cases in transaction propagation, including the following (requesting a RW transaction while the current transaction is RO):

class A {
  @Autowired
  private B b;

  @Transactional(readOnly = true)
  public void readOnly() {
    b.readWrite();
  }
}

class B {
  @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
  public void readWrite() {
    ...
  }
}

As expected, the call to b.readWrite() fails with an IllegalTransactionStateException. However, when I disable transaction synchronization in our transaction manager, I don't get an exception any more. In the code of AbstractPlatformTransactionManager.handleExistingtransaction(), I see that the check for this case uses TransactionSynchronizationManager.isCurrentTransactionReadOnly() which, obviously, returns false if transaction synchronization is turned off. I believe this is a bug. (It's possible that this follows from the semantics of transaction synchronization in which case I would be grateful if somebody could explain me the reasoning behind this).


Affects: 4.3.4

Issue Links:

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions