From a9992bb7c3a4b8ac3bed9755395d0be25e5b096b Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sat, 13 Apr 2013 23:25:41 +0000 Subject: Prevent NPE when using IsolationLevel.NONE. --- .../com/amazon/carbonado/txn/TransactionScope.java | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/main/java') 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 { // Caller must hold mLock. Txn getTxn() throws Exception { TransactionScope 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. -- cgit v1.2.3