User: mulder
Date: 00/10/25 16:54:38
Modified: src/main/org/jboss/minerva/xa XAClientConnection.java
XAConnectionImpl.java
Log:
More compliant with JDBC 2 Optional Package spec.
- Don't de-register a connection from transaction in case of error
- Don't allow commit, rollback, or setAutoCommit(true) if registered
with transaction
Also try to avoid a sporadic problem in load test where it tries to
deregister a connection from the transaction but it has no record
of a resource for the connection. I think this is a threading issue
where somehow the event is triggered again before the listener is
removed, though that's only a guess. Unfortunately I've only seen
the problem twice in about 50 5-minute runs, so it's pretty hard
to test for.
Revision Changes Path
1.5 +9 -7 jboss/src/main/org/jboss/minerva/xa/XAClientConnection.java
Index: XAClientConnection.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/xa/XAClientConnection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XAClientConnection.java 2000/10/03 17:32:13 1.4
+++ XAClientConnection.java 2000/10/25 23:54:37 1.5
@@ -32,7 +32,7 @@
* returned to the pool) until the transactional details are taken care of.
* This instance only lives as long as one client is using it - though we
* probably want to consider reusing it to save object allocations.
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @author Aaron Mulder ([EMAIL PROTECTED])
*/
public class XAClientConnection implements ConnectionWrapper {
@@ -172,12 +172,16 @@
public void setAutoCommit(boolean autoCommit) throws SQLException {
if(con == null) throw new SQLException(CLOSED);
+ if(((XAResourceImpl)xaCon.getXAResource()).isTransaction() && autoCommit)
+ throw new SQLException("Cannot set AutoCommit for a transactional
connection: See JDBC 2.0 Optional Package Specification section 7.1 (p25)");
+
try {
con.setAutoCommit(autoCommit);
} catch(SQLException e) {
setError(e);
throw e;
}
+
}
public boolean getAutoCommit() throws SQLException {
@@ -192,6 +196,8 @@
public void commit() throws SQLException {
if(con == null) throw new SQLException(CLOSED);
+ if(((XAResourceImpl)xaCon.getXAResource()).isTransaction())
+ throw new SQLException("Cannot commit a transactional connection: See
JDBC 2.0 Optional Package Specification section 7.1 (p25)");
try {
con.commit();
} catch(SQLException e) {
@@ -202,12 +208,8 @@
public void rollback() throws SQLException {
if(con == null) throw new SQLException(CLOSED);
- try {
- con.rollback();
- } catch(SQLException e) {
- setError(e);
- throw e;
- }
+ if(((XAResourceImpl)xaCon.getXAResource()).isTransaction())
+ throw new SQLException("Cannot rollback a transactional connection: See
JDBC 2.0 Optional Package Specification section 7.1 (p25)");
}
public void close() throws SQLException {
1.9 +3 -2 jboss/src/main/org/jboss/minerva/xa/XAConnectionImpl.java
Index: XAConnectionImpl.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/xa/XAConnectionImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XAConnectionImpl.java 2000/10/21 05:20:22 1.8
+++ XAConnectionImpl.java 2000/10/25 23:54:37 1.9
@@ -43,7 +43,7 @@
* also register a TransactionListener that will be notified when the
* Transaction is finished, and release the XAConnection at that time.</P>
* @see org.jboss.minerva.xa.TransactionListener
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
* @author Aaron Mulder ([EMAIL PROTECTED])
*/
public class XAConnectionImpl implements XAConnection, PooledObject {
@@ -179,7 +179,8 @@
}
public void removeConnectionEventListener(ConnectionEventListener listener) {
- listeners.remove(listener);
+ if(!listeners.remove(listener))
+ throw new IllegalArgumentException();
}
public Connection getConnection() {