关于规约TransactionMustHaveRollbackRule
- Dominant language
- Kotlin
- Stars
- 30.9k
- Forks
- 8k
- PR merge metrics
- No merged PRs in 30d
Description
## 规约原文
方法【%s】需要在Transactional注解指定rollbackFor或者在方法中显式的rollback
## 问题描述
https://github.com/alibaba/p3c/blob/master/p3c-pmd/src/main/resources/rulesets/java/ali-exception.xml
Positive example 2:
```
/**
* @author caikang
* @date 2017/04/07
*/
@Service
public class UserServiceImpl implements UserService {
@Override
@Transactional(rollbackFor = Exception.class)
public void save(User user) {
//some code
//db operation
}
}
```
以上例子中,save方法并不会产生Checked Exception,没必要加rollbackFor吧?
## 修改建议
当方法抛出Checked Exception时再触发
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the ali-exception.xml ruleset linked in the issue and locate TransactionMustHaveRollbackRule, then compare its handling of methods with checked and unchecked exceptions. Confirm the existing Positive example 2 behavior and inspect nearby rule tests if available. Done means the rule requires rollbackFor or explicit rollback only when a checked exception can be thrown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100