You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/10/21 15:01:24 UTC

[30/44] isis git commit: ISIS-1502: previous fix wasn't correctly handling nested transactions

ISIS-1502: previous fix wasn't correctly handling nested transactions


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/364a1aac
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/364a1aac
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/364a1aac

Branch: refs/heads/master
Commit: 364a1aac241af8a2c556d69d3f017cbdfafdad56
Parents: 5692abc
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Sep 29 11:51:02 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Sep 29 11:52:22 2016 +0100

----------------------------------------------------------------------
 .../runtime/system/transaction/IsisTransactionManager.java   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/364a1aac/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
index 560b2a1..8564a37 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
@@ -358,7 +358,10 @@ public class IsisTransactionManager implements SessionScopedComponent {
         // we don't decrement the transactionLevel just yet, because an exception might end up being thrown
         // (meaning there would be more faffing around to ensure that the transactionLevel
         // and state of the currentTransaction remain in sync)
-        if ( (transactionLevel - 1) == 0) {
+        int nextTransactionLevel = transactionLevel - 1;
+        if ( nextTransactionLevel > 0) {
+            transactionLevel --;
+        } else if ( nextTransactionLevel == 0) {
 
             //
             // TODO: granted, this is some fairly byzantine coding.  but I'm trying to account for different types
@@ -433,7 +436,8 @@ public class IsisTransactionManager implements SessionScopedComponent {
                 getCurrentTransaction().commit();
             }
 
-        } else if (transactionLevel < 0) {
+        } else {
+            // transactionLevel < 0
             LOG.error("endTransaction: transactionLevel={}", transactionLevel);
             transactionLevel = 0;
             IllegalStateException ex = new IllegalStateException(" no transaction running to end (transactionLevel < 0)");