You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2009/06/26 14:27:19 UTC
svn commit: r788674 - in /db/derby/code/trunk/java:
client/org/apache/derby/client/net/NetXAConnectionRequest.java
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
Author: kahatlen
Date: Fri Jun 26 12:27:18 2009
New Revision: 788674
URL: http://svn.apache.org/viewvc?rev=788674&view=rev
Log:
DERBY-4232: XAResource.setTransactionTimeout() makes XAResource.start() fail with the client driver
Only send the timeout property when start() is called with TMNOFLAGS,
as specified in DRDAv4 (volume 3, SYNCCTL, page 872).
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java?rev=788674&r1=788673&r2=788674&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionRequest.java Fri Jun 26 12:27:18 2009
@@ -73,11 +73,15 @@
}
writeXAFlags(CodePoint.XAFLAGS, xaFlags);
+
// Check whether the timeout value was specified.
// Value less than 0 means no timeout is specified.
- if (xaTimeout >= 0) {
+ // DERBY-4232: The DRDA spec says that SYNCCTL should only have a
+ // timeout property if TMNOFLAGS is specified.
+ if (xaTimeout >= 0 && xaFlags == XAResource.TMNOFLAGS) {
writeXATimeout(CodePoint.TIMEOUT, xaTimeout);
}
+
updateLengthBytes();
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java?rev=788674&r1=788673&r2=788674&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java Fri Jun 26 12:27:18 2009
@@ -45,6 +45,7 @@
import org.apache.derbyTesting.junit.J2EEDataSource;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.junit.XATestUtil;
/** The test of the properties of the XA transaction interface implementation.
*/
@@ -287,6 +288,75 @@
}
/**
+ * DERBY-4232: Test that an XA transaction can be suspended and resumed
+ * when a timeout is in effect.
+ */
+ public void testTransactionTimeoutAndSuspendResume() throws Exception {
+ XADataSource xads = J2EEDataSource.getXADataSource();
+ XAConnection xac = xads.getXAConnection();
+ XAResource xar = xac.getXAResource();
+ Xid xid = XATestUtil.getXid(1, 2, 3);
+
+ // Start work in a new transaction with a timeout
+ xar.setTransactionTimeout(500);
+ xar.start(xid, XAResource.TMNOFLAGS);
+
+ // Suspend the transaction
+ xar.end(xid, XAResource.TMSUSPEND);
+
+ // Resume the transaction (used to fail with a XAER_PROTO on the
+ // network client)
+ xar.start(xid, XAResource.TMRESUME);
+
+ // End the transaction and free up the resources
+ xar.end(xid, XAResource.TMSUCCESS);
+ xar.rollback(xid);
+ xac.close();
+ }
+
+ /**
+ * DERBY-4232: Test that two branches can be joined after the timeout has
+ * been set.
+ */
+ public void testTransactionTimeoutAndJoin() throws Exception {
+ XADataSource xads = J2EEDataSource.getXADataSource();
+ XAConnection xac1 = xads.getXAConnection();
+ XAResource xar1 = xac1.getXAResource();
+ Xid xid1 = XATestUtil.getXid(4, 5, 6);
+
+ // Start/end work in a new transaction
+ xar1.setTransactionTimeout(500);
+ xar1.start(xid1, XAResource.TMNOFLAGS);
+ xar1.end(xid1, XAResource.TMSUCCESS);
+
+ // Create a new branch that can be joined with the existing one
+ XAConnection xac2 = xads.getXAConnection();
+ XAResource xar2 = xac2.getXAResource();
+ xar2.setTransactionTimeout(500);
+
+ // Do some work on the new branch before joining (the bug won't be
+ // reproduced if we join with a fresh branch)
+ Xid xid2 = XATestUtil.getXid(4, 5, 7);
+ xar2.start(xid2, XAResource.TMNOFLAGS);
+ xar2.end(xid2, XAResource.TMSUCCESS);
+ xar2.rollback(xid2);
+
+ assertTrue(
+ "Branches can only be joined if RM is same",
+ xar1.isSameRM(xar2));
+
+ // Join the branches. This used to fail with XAER_PROTO on the
+ // network client.
+ xar2.start(xid1, XAResource.TMJOIN);
+
+ // End the transaction and free up the resources
+ xar2.end(xid1, XAResource.TMSUCCESS);
+ xar2.rollback(xid1);
+ xac1.close();
+ xac2.close();
+ }
+
+ /**
* DERBY-4141 XAExceptions caused by SQLExceptions should have a
* non-zero errorCode. SESSION_SEVERITY or greater map to
* XAException.XAER_RMFAIL. Lesser exceptions map to XAException.XAER_RMERR