Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 21220 invoked from network); 26 Jun 2009 12:27:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Jun 2009 12:27:35 -0000 Received: (qmail 86067 invoked by uid 500); 26 Jun 2009 12:27:46 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 86041 invoked by uid 500); 26 Jun 2009 12:27:45 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 86032 invoked by uid 99); 26 Jun 2009 12:27:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jun 2009 12:27:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jun 2009 12:27:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 366622388896; Fri, 26 Jun 2009 12:27:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Fri, 26 Jun 2009 12:27:19 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090626122719.366622388896@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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