summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-01-20 05:30:43 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-01-20 05:30:43 +0000
commit0040cf72f1a878d5e19253036ae38b09a6a48567 (patch)
treec88818b634ce5658c1ed92e4716df46b30ad035a /src/main/java/com/amazon/carbonado
parentd3893bcee8df9db78538e5eee23a608fa41cd77c (diff)
Ensure that exited transaction cleans up the local scope even when an exception is thrown.
Diffstat (limited to 'src/main/java/com/amazon/carbonado')
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionScope.java53
1 files changed, 36 insertions, 17 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
index daf4992..1e294e4 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
@@ -359,29 +359,48 @@ public class TransactionScope<Txn> {
scope.mLock.lock();
try {
if (!mExited) {
- if (mChild != null) {
- mChild.exit();
- }
-
- closeCursors();
+ Exception exception = null;
+ try {
+ if (mChild != null) {
+ try {
+ mChild.exit();
+ } catch (Exception e) {
+ if (exception == null) {
+ exception = e;
+ }
+ }
+ }
- if (mTxn != null) {
try {
- if (mParent == null || mParent.mTxn != mTxn) {
- try {
- scope.mTxnMgr.abortTxn(mTxn);
- } catch (Throwable e) {
- throw ExceptionTransformer.getInstance().toPersistException(e);
+ closeCursors();
+ } catch (Exception e) {
+ if (exception == null) {
+ exception = e;
+ }
+ }
+
+ if (mTxn != null) {
+ try {
+ if (mParent == null || mParent.mTxn != mTxn) {
+ try {
+ scope.mTxnMgr.abortTxn(mTxn);
+ } catch (Exception e) {
+ if (exception == null) {
+ exception = e;
+ }
+ }
}
+ } finally {
+ mTxn = null;
}
- } finally {
- mTxn = null;
+ }
+ } finally {
+ scope.mActive = mParent;
+ mExited = true;
+ if (exception != null) {
+ throw ExceptionTransformer.getInstance().toPersistException(exception);
}
}
-
- scope.mActive = mParent;
-
- mExited = true;
}
} finally {
scope.mLock.unlock();