You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by da...@apache.org on 2013/11/03 13:41:57 UTC

[2/3] git commit: AMQ-1063: Fixed journaled JDBC checkpoint which would mark inTx eager, which was wrong, as getting the JDBC connection may fail. So the mark inTx should only happen if getting the connection was succesful.

AMQ-1063: Fixed journaled JDBC checkpoint which would mark inTx eager, which was wrong, as getting the JDBC connection may fail. So the mark inTx should only happen if getting the connection was succesful.


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

Branch: refs/heads/trunk
Commit: d0f48b3ee504650330425707c363ea103be3c3dd
Parents: af1edf4
Author: Claus Ibsen <cl...@gmail.com>
Authored: Sun Nov 3 11:54:14 2013 +0100
Committer: Claus Ibsen <cl...@gmail.com>
Committed: Sun Nov 3 11:54:14 2013 +0100

----------------------------------------------------------------------
 .../activemq/store/jdbc/TransactionContext.java       | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/d0f48b3e/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
----------------------------------------------------------------------
diff --git a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
index c776306..66163b6 100755
--- a/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
+++ b/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/TransactionContext.java
@@ -30,8 +30,6 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Helps keep track of the current transaction/JDBC connection.
- * 
- * 
  */
 public class TransactionContext {
 
@@ -40,7 +38,7 @@ public class TransactionContext {
     private final DataSource dataSource;
     private final JDBCPersistenceAdapter persistenceAdapter;
     private Connection connection;
-    private boolean inTx;
+    private volatile boolean inTx;
     private PreparedStatement addMessageStatement;
     private PreparedStatement removedMessageStatement;
     private PreparedStatement updateLastAckStatement;
@@ -68,12 +66,14 @@ public class TransactionContext {
                 IOException ioe = IOExceptionSupport.create(e);
                 persistenceAdapter.getBrokerService().handleIOException(ioe);
                 throw ioe;
-
             }
 
             try {
                 connection.setTransactionIsolation(transactionIsolation);
             } catch (Throwable e) {
+                // ignore
+                LOG.trace("Cannot set transaction isolation to " + transactionIsolation + " due " + e.getMessage()
+                        + ". This exception is ignored.", e);
             }
         }
         return connection;
@@ -147,7 +147,8 @@ public class TransactionContext {
                         connection.close();
                     }
                 } catch (Throwable e) {
-                    LOG.warn("Close failed: " + e.getMessage(), e);
+                    // ignore
+                    LOG.trace("Closing connection failed due: " + e.getMessage() + ". This exception is ignored.", e);
                 } finally {
                     connection = null;
                 }
@@ -159,8 +160,9 @@ public class TransactionContext {
         if (inTx) {
             throw new IOException("Already started.");
         }
-        inTx = true;
         connection = getConnection();
+        // only mark in tx if we could get a connection
+        inTx = true;
     }
 
     public void commit() throws IOException {