[Mulgara-svn] r1354 - trunk/src/jar/resolver/java/org/mulgara/resolver
ronald at mulgara.org
ronald at mulgara.org
Thu Oct 23 13:12:19 UTC 2008
Author: ronald
Date: 2008-10-23 06:12:18 -0700 (Thu, 23 Oct 2008)
New Revision: 1354
Modified:
trunk/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java
trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransaction.java
Log:
According to Table 1 in the JTA spec we can end(TMFAIL/TMSUCCESS) a suspended
resource, so no need to resume it first.
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java 2008-10-23 13:12:11 UTC (rev 1353)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/ExternalTransactionUnitTest.java 2008-10-23 13:12:18 UTC (rev 1354)
@@ -2179,7 +2179,7 @@
resource1.commit(xid1, true);
assertEquals(1, mockRes.startCnt);
assertEquals(3, mockRes.suspendCnt);
- assertEquals(3, mockRes.resumeCnt);
+ assertEquals(2, mockRes.resumeCnt);
assertEquals(1, mockRes.endCnt);
assertEquals(1, mockRes.prepareCnt);
assertEquals(1, mockRes.commitCnt);
@@ -2207,7 +2207,7 @@
resource1.commit(xid1, true);
assertEquals(1, mockRes.startCnt);
assertEquals(2, mockRes.suspendCnt);
- assertEquals(2, mockRes.resumeCnt);
+ assertEquals(1, mockRes.resumeCnt);
assertEquals(1, mockRes.endCnt);
assertEquals(1, mockRes.prepareCnt);
assertEquals(1, mockRes.commitCnt);
@@ -2257,7 +2257,7 @@
theRes.rollback(theXid);
assertEquals(1, theMockRes.startCnt);
assertEquals(6, theMockRes.suspendCnt);
- assertEquals(6, theMockRes.resumeCnt);
+ assertEquals(5, theMockRes.resumeCnt);
assertEquals(1, theMockRes.endCnt);
assertEquals(0, theMockRes.prepareCnt);
assertEquals(0, theMockRes.commitCnt);
@@ -2338,22 +2338,22 @@
// res.end fails on end with unspecified error-code
doResourceFailureTest(10, session1, resource1, testModel, -1, -1, -1, 1, false, 0, false,
1, 2, 1, 0,
- 1, 2, 2, 1, 0, 0, 0);
+ 1, 2, 1, 1, 0, 0, 0);
// res.end fails on end with rollback error-code
doResourceFailureTest(11, session1, resource1, testModel, -1, -1, -1, 1, false, RB, false,
1, 2, 1, 0,
- 1, 2, 2, 1, 0, 0, 1);
+ 1, 2, 1, 1, 0, 0, 1);
// res.prepare fails with unspecified error-code
doResourceFailureTest(12, session1, resource1, testModel, -1, -1, -1, -1, true, 0, false,
1, 2, 1, 0,
- 1, 2, 2, 1, 1, 0, 1);
+ 1, 2, 1, 1, 1, 0, 1);
// res.prepare fails with rollback error-code
doResourceFailureTest(13, session1, resource1, testModel, -1, -1, -1, -1, true, RB, false,
1, 2, 1, 0,
- 1, 2, 2, 1, 1, 0, 0);
+ 1, 2, 1, 1, 1, 0, 0);
} finally {
session1.close();
}
@@ -2464,13 +2464,15 @@
public void end(Xid xid, int flags) throws XAException {
super.end(xid, flags);
- if (!xid.equals(currTxn.get())) {
- throw new XAException("mismatched transaction end");
- }
- currTxn.set(null);
+ if (!(state == State.SUSPENDED && (flags == XAResource.TMSUCCESS || flags == XAResource.TMFAIL))) {
+ if (!xid.equals(currTxn.get())) {
+ throw new XAException("mismatched transaction end");
+ }
+ currTxn.set(null);
- if (state != State.ACTIVE) {
- throw new XAException("resource not active: " + state);
+ if (state != State.ACTIVE) {
+ throw new XAException("resource not active: " + state);
+ }
}
state = (flags == XAResource.TMSUSPEND) ? State.SUSPENDED : State.ENDED;
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransaction.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransaction.java 2008-10-23 13:12:11 UTC (rev 1353)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransaction.java 2008-10-23 13:12:18 UTC (rev 1354)
@@ -381,9 +381,6 @@
EnlistableResource eres = iter.next();
XAResource res = xaResources.get(eres);
try {
- if (xaResState == ResourceState.SUSPENDED) {
- res.start(xid, XAResource.TMRESUME);
- }
res.end(xid, flags);
} catch (XAException xae) {
iter.remove();
More information about the Mulgara-svn
mailing list