summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2013-04-13 23:25:41 +0000
committerBrian S. O'Neill <bronee@gmail.com>2013-04-13 23:25:41 +0000
commita9992bb7c3a4b8ac3bed9755395d0be25e5b096b (patch)
tree96772b960cbaf4d1bad852aeca43f638b2523e9d /src/main
parentb926a082939c526d80bbab293eee1a2e2b1413a7 (diff)
Prevent NPE when using IsolationLevel.NONE.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/amazon/carbonado/txn/TransactionScope.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
index b39d091..6e94b91 100644
--- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
+++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java
@@ -597,21 +597,26 @@ public class TransactionScope<Txn> {
// Caller must hold mLock.
Txn getTxn() throws Exception {
TransactionScope<Txn> scope = mScope;
- if (mTxn != null) {
- scope.mTxnMgr.reuseTxn(mTxn);
+ Txn txn = mTxn;
+ if (txn != null) {
+ scope.mTxnMgr.reuseTxn(txn);
+ if (mForUpdate) {
+ scope.mTxnMgr.setForUpdate(txn, true);
+ }
} else {
Txn parentTxn = (mParent == null || mTop) ? null : mParent.getTxn();
if (mTimeoutUnit == null) {
- mTxn = scope.mTxnMgr.createTxn(parentTxn, mLevel);
+ txn = scope.mTxnMgr.createTxn(parentTxn, mLevel);
} else {
- mTxn = scope.mTxnMgr.createTxn(parentTxn, mLevel,
- mDesiredLockTimeout, mTimeoutUnit);
+ txn = scope.mTxnMgr.createTxn(parentTxn, mLevel,
+ mDesiredLockTimeout, mTimeoutUnit);
+ }
+ mTxn = txn;
+ if (mForUpdate & txn != null) {
+ scope.mTxnMgr.setForUpdate(txn, true);
}
}
- if (mForUpdate) {
- scope.mTxnMgr.setForUpdate(mTxn, true);
- }
- return mTxn;
+ return txn;
}
// Caller must hold mLock.