codingapi / codingapi/tx-lcn

5.0.2下,手动回滚事务失效

Aperta
#450 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
4.2k
Fork
1.4k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

- [ ] I have searched the [issues](https://github.com/codingapi/tx-lcn/issues) of this repository and believe that this is not a duplicate.

### 1. Bug Description
5.0.2下,手动回滚事务失效

### 2. Environment:
- JDK version:1.8
- OS:
- TX-LCN version:5.0.2
- Others:

```
@Override
@LcnTransaction
@Transactional(rollbackFor = {Exception.class})
public boolean test() {
B_file b = new B_file();
b.setUrl("515645646");
b.setCategory("0");
save(b);
try {
int i = 1 / 0;// 异常
return true;
} catch (Exception e) {
// 事务回滚
System.out.println("事务回滚");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();// 关键
return false;
}
}
```
以上是demo代码,下面的手动回滚事务会失效,如果这时候把下面的手动回滚事务改成 throw new RuntimeException();就可以成功回滚,但是这样对业务来是不友善,求解决

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start with the shown test() method and reproduce it on JDK 8 with TX-LCN 5.0.2, comparing TransactionAspectSupport.currentTransactionStatus().setRollbackOnly() with throwing RuntimeException. Trace the @LcnTransaction and @Transactional transaction handling, and consider the issue done when the saved record is rolled back for the handled-exception case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, spring
Ambito
backend, distributed-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.