Skip to content

Commit

Permalink
Merge pull request #13855 from Postremus/13776-fix-wrong-transaction-…
Browse files Browse the repository at this point in the history
…exception

Ensure that suspended transaction is always resumed
  • Loading branch information
Sanne authored Dec 14, 2020
2 parents 215c408 + 4b8881c commit e3c3968
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,19 @@ protected void handleException(InvocationContext ic, Exception e, Transaction tx

protected void endTransaction(TransactionManager tm, Transaction tx, RunnableWithException afterEndTransaction)
throws Exception {
if (tx != tm.getTransaction()) {
throw new RuntimeException(jtaLogger.i18NLogger.get_wrong_tx_on_thread());
}
try {
if (tx != tm.getTransaction()) {
throw new RuntimeException(jtaLogger.i18NLogger.get_wrong_tx_on_thread());
}

if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
tm.rollback();
} else {
tm.commit();
if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
tm.rollback();
} else {
tm.commit();
}
} finally {
afterEndTransaction.run();
}

afterEndTransaction.run();
}

protected boolean setUserTransactionAvailable(boolean available) {
Expand Down

0 comments on commit e3c3968

Please sign in to comment.