[Mulgara-svn] r1894 - trunk/src/jar/querylang/java/org/mulgara/itql

pag at mulgara.org pag at mulgara.org
Wed Jan 27 19:21:30 UTC 2010


Author: pag
Date: 2010-01-27 11:21:29 -0800 (Wed, 27 Jan 2010)
New Revision: 1894

Modified:
   trunk/src/jar/querylang/java/org/mulgara/itql/TqlAutoInterpreter.java
Log:
Fixed TqlAutoInterpreter to correctly deal with all three operations for changing transaction state.

Modified: trunk/src/jar/querylang/java/org/mulgara/itql/TqlAutoInterpreter.java
===================================================================
--- trunk/src/jar/querylang/java/org/mulgara/itql/TqlAutoInterpreter.java	2010-01-27 19:20:20 UTC (rev 1893)
+++ trunk/src/jar/querylang/java/org/mulgara/itql/TqlAutoInterpreter.java	2010-01-27 19:21:29 UTC (rev 1894)
@@ -353,13 +353,17 @@
     // check if the transaction state changed on a setAutocommit operations, or if the command is a Tx operation
     if (inTransaction == conn.getAutoCommit() || cmd.isTxCommitRollback()) {
       // check that transaction changes came from setAutoCommit commands
-      assert inTransaction != conn.getAutoCommit() || cmd instanceof org.mulgara.query.operation.SetAutoCommit: "Got a state change on " + cmd.getClass() + " instead of SetAutoCommit";
+      assert inTransaction != conn.getAutoCommit() ||
+             cmd instanceof org.mulgara.query.operation.SetAutoCommit ||
+             cmd instanceof org.mulgara.query.operation.Commit ||
+             cmd instanceof org.mulgara.query.operation.Rollback :
+             "Got a state change on " + cmd.getClass() + " instead of SetAutoCommit/Commit/Rollback";
       // check that if we are starting a transaction then the transConnections list is empty
       assert inTransaction != conn.getAutoCommit() || conn.getAutoCommit() || transConnections.isEmpty();
       // save the number of active connections
       int activeConnections = transConnections.size();
       // handle the transaction operation
-      handleTxOp((TxOp)cmd);
+      handleTxOp(cmd);
       // check that if we have left a transaction, then the connection list is empty
       assert inTransaction || transConnections.isEmpty();
       // check that if we are still in a transaction, then the connection list has not changed
@@ -375,7 +379,7 @@
    * @param op The operation to end the transaction.
    * @throws QueryException The operation could not be successfully performed.
    */
-  private void handleTxOp(TxOp op) throws QueryException {
+  private void handleTxOp(Command op) throws QueryException {
     // used to record the first exception, if there is one.
     QueryException qe = null;
     String errorMessage = null;
@@ -393,11 +397,15 @@
           qe = e;
           errorMessage = op.getResultMessage();
         }
+      } catch (Exception e) {
+        throw new QueryException("Unexpected exception during operation: " + op, e);
       }
     }
     // will only get here once all connections were processed.
-    inTransaction = op.stayInTx();
-    if (!inTransaction) transConnections.clear();
+    if (op instanceof TxOp) {
+      inTransaction = ((TxOp)op).stayInTx();
+      if (!inTransaction) transConnections.clear();
+    }
 
     // if an exception was recorded, then throw it
     if (qe != null) {




More information about the Mulgara-svn mailing list