From f32b01eb3a9696bb82a103f4908e2852f5edeca6 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Wed, 17 Feb 2010 19:45:55 +0000 Subject: Rollback transaction if commit fails. --- src/main/java/com/amazon/carbonado/txn/TransactionScope.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main/java/com/amazon/carbonado') diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java index 61f4b6a..8bad678 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java @@ -196,6 +196,7 @@ public class TransactionScope { /** * Returns the implementation for the active transaction, only if it exists. + * (does not create a transaction like getTxn() */ Txn getActiveTxn() { mLock.lock(); @@ -371,6 +372,11 @@ public class TransactionScope { mTxn = null; } } catch (Throwable e) { + try { + scope.mTxnMgr.abortTxn(mTxn); + } catch (Throwable e2) { + // Ignore. At least we tried to clean up. + } mTxn = null; throw ExceptionTransformer.getInstance().toPersistException(e); } -- cgit v1.2.3