https://issues.apache.org/jira/browse/AMQ-1063 - revert delayed change to inTx flag, now cleared before exception is thrown by getConnection, this ensures jms transactions can use autocommit=false

This commit is contained in:
gtully 2013-12-09 17:01:56 +00:00
parent 3797da64fc
commit b7c430d068
1 changed files with 4 additions and 3 deletions

View File

@ -38,7 +38,7 @@ public class TransactionContext {
private final DataSource dataSource; private final DataSource dataSource;
private final JDBCPersistenceAdapter persistenceAdapter; private final JDBCPersistenceAdapter persistenceAdapter;
private Connection connection; private Connection connection;
private volatile boolean inTx; private boolean inTx;
private PreparedStatement addMessageStatement; private PreparedStatement addMessageStatement;
private PreparedStatement removedMessageStatement; private PreparedStatement removedMessageStatement;
private PreparedStatement updateLastAckStatement; private PreparedStatement updateLastAckStatement;
@ -63,6 +63,8 @@ public class TransactionContext {
} }
} catch (SQLException e) { } catch (SQLException e) {
JDBCPersistenceAdapter.log("Could not get JDBC connection: ", e); JDBCPersistenceAdapter.log("Could not get JDBC connection: ", e);
inTx = false;
close();
IOException ioe = IOExceptionSupport.create(e); IOException ioe = IOExceptionSupport.create(e);
persistenceAdapter.getBrokerService().handleIOException(ioe); persistenceAdapter.getBrokerService().handleIOException(ioe);
throw ioe; throw ioe;
@ -160,9 +162,8 @@ public class TransactionContext {
if (inTx) { if (inTx) {
throw new IOException("Already started."); throw new IOException("Already started.");
} }
connection = getConnection();
// only mark in tx if we could get a connection
inTx = true; inTx = true;
connection = getConnection();
} }
public void commit() throws IOException { public void commit() throws IOException {