diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/amazon/carbonado/txn/TransactionManager.java | 2 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/txn/TransactionScope.java | 10 |
2 files changed, 11 insertions, 1 deletions
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<Txn> { // Called by TransactionScope.
boolean setLocalScope(TransactionScope<Txn> scope, boolean detached) {
TransactionScope<Txn> 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<Txn> { }
}
+ // 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.
|