summaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/amazon/carbonado/spi/TransactionManager.java4
-rw-r--r--src/main/java/com/amazon/carbonado/spi/TransactionScope.java4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/com/amazon/carbonado/spi/TransactionManager.java b/src/main/java/com/amazon/carbonado/spi/TransactionManager.java
index a2b1375..a63784a 100644
--- a/src/main/java/com/amazon/carbonado/spi/TransactionManager.java
+++ b/src/main/java/com/amazon/carbonado/spi/TransactionManager.java
@@ -96,9 +96,9 @@ public abstract class TransactionManager<Txn> {
}
// Called by TransactionScope.
- boolean setLocalScope(TransactionScope<Txn> scope) {
+ boolean setLocalScope(TransactionScope<Txn> scope, boolean detached) {
TransactionScope<Txn> existing = mLocalScope.get();
- if (existing == null || existing == scope) {
+ if ((existing == null && detached) || existing == scope) {
mLocalScope.set(scope);
return true;
}
diff --git a/src/main/java/com/amazon/carbonado/spi/TransactionScope.java b/src/main/java/com/amazon/carbonado/spi/TransactionScope.java
index 82a20eb..60e5f84 100644
--- a/src/main/java/com/amazon/carbonado/spi/TransactionScope.java
+++ b/src/main/java/com/amazon/carbonado/spi/TransactionScope.java
@@ -219,8 +219,10 @@ public class TransactionScope<Txn> {
public void attach() {
mLock.lock();
try {
- if (mTxnMgr.setLocalScope(this)) {
+ if (mTxnMgr.setLocalScope(this, mDetached)) {
mDetached = false;
+ } else if (!mDetached) {
+ throw new IllegalStateException("Transaction scope is not detached");
} else {
throw new IllegalStateException
("Current thread has a different transaction already attached");