mirror of https://github.com/apache/activemq.git
use valid error code (in place of xa_ok) for xaexceptions in the absense of marshalled exception content from the broker
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1515783 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
25a1dd071a
commit
f155083a61
|
@ -772,6 +772,11 @@ public class TransactionContext implements XAResource {
|
||||||
XAException original = (XAException)e.getCause();
|
XAException original = (XAException)e.getCause();
|
||||||
XAException xae = new XAException(original.getMessage());
|
XAException xae = new XAException(original.getMessage());
|
||||||
xae.errorCode = original.errorCode;
|
xae.errorCode = original.errorCode;
|
||||||
|
if (xae.errorCode == XA_OK) {
|
||||||
|
// detail not unmarshalled see: org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.createThrowable
|
||||||
|
// so use a valid generic error code in place of ok
|
||||||
|
xae.errorCode = XAException.XAER_RMERR;
|
||||||
|
}
|
||||||
xae.initCause(original);
|
xae.initCause(original);
|
||||||
return xae;
|
return xae;
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,12 +411,35 @@ public class ActiveMQXAConnectionFactoryTest extends CombinationTestSupport {
|
||||||
} catch (javax.jms.IllegalStateException expected) {}
|
} catch (javax.jms.IllegalStateException expected) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRollbackXaErrorCode() throws Exception {
|
||||||
|
String brokerName = "rollbackErrorCode";
|
||||||
|
BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:0)/" + brokerName));
|
||||||
|
broker.start();
|
||||||
|
broker.waitUntilStarted();
|
||||||
|
ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri());
|
||||||
|
XAConnection connection = (XAConnection)cf.createConnection();
|
||||||
|
connection.start();
|
||||||
|
XASession session = connection.createXASession();
|
||||||
|
XAResource resource = session.getXAResource();
|
||||||
|
|
||||||
|
Xid tid = createXid();
|
||||||
|
try {
|
||||||
|
resource.rollback(tid);
|
||||||
|
fail("Expected xa exception on no tx");
|
||||||
|
} catch (XAException expected) {
|
||||||
|
LOG.info("got expected xa", expected);
|
||||||
|
assertTrue("not zero", expected.errorCode != XAResource.XA_OK);
|
||||||
|
}
|
||||||
|
connection.close();
|
||||||
|
broker.stop();
|
||||||
|
}
|
||||||
|
|
||||||
private void assertTransactionGoneFromFailoverState(
|
private void assertTransactionGoneFromFailoverState(
|
||||||
ActiveMQXAConnection connection1, Xid tid) throws Exception {
|
ActiveMQXAConnection connection1, Xid tid) throws Exception {
|
||||||
|
|
||||||
FailoverTransport transport = (FailoverTransport) connection1.getTransport().narrow(FailoverTransport.class);
|
FailoverTransport transport = (FailoverTransport) connection1.getTransport().narrow(FailoverTransport.class);
|
||||||
TransactionInfo info = new TransactionInfo(connection1.getConnectionInfo().getConnectionId(), new XATransactionId(tid), TransactionInfo.COMMIT_ONE_PHASE);
|
TransactionInfo info = new TransactionInfo(connection1.getConnectionInfo().getConnectionId(), new XATransactionId(tid), TransactionInfo.COMMIT_ONE_PHASE);
|
||||||
assertNull("transaction shold not exist in the state tracker",
|
assertNull("transaction should not exist in the state tracker",
|
||||||
transport.getStateTracker().processCommitTransactionOnePhase(info));
|
transport.getStateTracker().processCommitTransactionOnePhase(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue