activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [10/10] 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.
Date Wed, 12 Mar 2014 12:35:55 GMT
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/c1fc98a0
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/c1fc98a0
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/c1fc98a0

Branch: refs/heads/activemq-5.9
Commit: c1fc98a05a5e96128096c77c4215224dfc879134
Parents: a097fb5
Author: Claus Ibsen <claus.ibsen@gmail.com>
Authored: Sun Nov 3 11:54:14 2013 +0100
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Wed Mar 12 08:32:53 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/c1fc98a0/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 {


Mime
View raw message