diff options
| author | Brian S. O'Neill <bronee@gmail.com> | 2010-02-17 22:26:51 +0000 | 
|---|---|---|
| committer | Brian S. O'Neill <bronee@gmail.com> | 2010-02-17 22:26:51 +0000 | 
| commit | 582b360c15baa33586f15963931e390f718070f0 (patch) | |
| tree | afeba307cea720b41ce3b82cce820aa268dfe8f7 /src/test/java/com/amazon | |
| parent | 964e0d7c6d6a903ab0031f46b7bd1da51b35d393 (diff) | |
Fix transaction attach/detach test.
Diffstat (limited to 'src/test/java/com/amazon')
| -rw-r--r-- | src/test/java/com/amazon/carbonado/txn/TestTransactionManager.java | 17 | 
1 files changed, 12 insertions, 5 deletions
diff --git a/src/test/java/com/amazon/carbonado/txn/TestTransactionManager.java b/src/test/java/com/amazon/carbonado/txn/TestTransactionManager.java index be43b88..d226e8d 100644 --- a/src/test/java/com/amazon/carbonado/txn/TestTransactionManager.java +++ b/src/test/java/com/amazon/carbonado/txn/TestTransactionManager.java @@ -117,17 +117,24 @@ public class TestTransactionManager extends TestCase {          txn2.exit();
 +        // Thread with txn2 was attached but is inactive, so txn thread can
 +        // steal it. Exiting a top-level transaction implicitly detaches
 +        // it. This can happen if a remote connection is dropped, but the
 +        // thread which is automatically exiting the open transaction isn't the
 +        // one which is attached. Detach is not allowed, so it can only exit.
 +        txn.attach();
 +
          try {
 -            txn.attach();
 +            txn2.detach();
              fail();
          } catch (IllegalStateException e) {
 +            // Cannot detach since attach was stolen. Throwing an exception
 +            // here is the correct thing, since it indicates a bug in the
 +            // application. The txn2 thread didn't detach properly and it let
 +            // the txn thread try to get the transaction.
          }
          txn.detach();
 -
 -        txn2.detach();
 -
 -        txn.detach();
          txn.attach();
          txn.detach();
  | 
