spring-projects / spring-projects/spring-framework
Improve documentation to clarify coordination of multiple transaction managers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Given two transaction managers tm1 and tm2, it's unclear that a transaction created by tm2 will or not participate in an existing transaction created by tm1. According to my investigation, the answer is yes if they share the same underlying resource, such as DataSourceTransactionManager for example:
@Test
public void test(@Autowired DataSource dataSource) {
DataSourceTransactionManager tm1 = new DataSourceTransactionManager(dataSource);
DataSourceTransactionManager tm2 = new DataSourceTransactionManager(dataSource);
TransactionTemplate tt1 = new TransactionTemplate(tm1);
TransactionTemplate tt2 = new TransactionTemplate(tm2);
tt1.executeWithoutResult(s1 -> {
assertThat(s1.isNewTransaction()).isTrue();
tt2.executeWithoutResult(s2 -> {
assertThat(s2.isNewTransaction()).isFalse();
});
});
}
It would be nice if the reference manual expounded on it and the Javadoc mentioned it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the transaction coordination section in the reference manual and the Javadoc for the relevant transaction manager classes. Use the provided DataSourceTransactionManager example to verify the behavior when two managers share a DataSource. Done means both references explain when the second transaction participates in the existing transaction and when it does not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100