From ca6d4484142d8144f7567a37ed448babe294fda8 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 20 Dec 2009 02:54:41 +0000 Subject: Allow transaction to attach if existing scope is inactive. --- src/main/java/com/amazon/carbonado/txn/TransactionManager.java | 2 +- src/main/java/com/amazon/carbonado/txn/TransactionScope.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java index 528ade5..36d2e22 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionManager.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionManager.java @@ -98,7 +98,7 @@ public abstract class TransactionManager { // Called by TransactionScope. boolean setLocalScope(TransactionScope scope, boolean detached) { TransactionScope existing = mLocalScope.get(); - if ((existing == null && detached) || existing == scope) { + if (((existing == null || existing.isInactive()) && detached) || existing == scope) { mLocalScope.set(scope); return true; } diff --git a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java index 29c173c..bce8ca6 100644 --- a/src/main/java/com/amazon/carbonado/txn/TransactionScope.java +++ b/src/main/java/com/amazon/carbonado/txn/TransactionScope.java @@ -258,6 +258,16 @@ public class TransactionScope { } } + // Called by TransactionManager. + boolean isInactive() { + mLock.lock(); + try { + return mActive == null; + } finally { + mLock.unlock(); + } + } + /** * Exits all transactions and closes all cursors. Should be called only * when repository is closed. -- cgit v1.2.3