codingapi / codingapi/tx-lcn

5.0.2下,手动回滚事务失效

Offen
#450 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
4.2k
Forks
1.4k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- [ ] 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();就可以成功回滚,但是这样对业务来是不友善,求解决

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, spring
Bereich
backend, distributed-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.