Make sure uncommitted txn is rolled back (#665)

* Make sure uncommit txn is rolled back

The try block around commit that catches RuntimeException should also
catch Error, which is also unchecked.
This commit is contained in:
Weimin Yu 2020-07-06 17:39:13 -04:00 committed by GitHub
parent 43230eee09
commit a871564ea2

View file

@ -101,7 +101,8 @@ public class JpaTransactionManagerImpl implements JpaTransactionManager {
T result = work.get(); T result = work.get();
txn.commit(); txn.commit();
return result; return result;
} catch (RuntimeException e) { } catch (RuntimeException | Error e) {
// Error is unchecked!
try { try {
txn.rollback(); txn.rollback();
logger.atWarning().log("Error during transaction; transaction rolled back"); logger.atWarning().log("Error during transaction; transaction rolled back");