summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/txn
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2010-02-17 19:45:55 +0000
committerBrian S. O'Neill <bronee@gmail.com>2010-02-17 19:45:55 +0000
commitf32b01eb3a9696bb82a103f4908e2852f5edeca6 (patch)
tree09428793db75d30caf5892f4e49d28c509326400 /src/main/java/com/amazon/carbonado/txn
parent718eb5e99395f3c9f216fb7421d33a6a58cca4c6 (diff)
Rollback transaction if commit fails.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/txn')
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionScope.java6
1 files changed, 6 insertions, 0 deletions
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<Txn> {
/**
* 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<Txn> {
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);
}