summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();