activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1515783 - in /activemq/trunk: activemq-client/src/main/java/org/apache/activemq/TransactionContext.java activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
Date Tue, 20 Aug 2013 11:21:43 GMT
Author: gtully
Date: Tue Aug 20 11:21:43 2013
New Revision: 1515783

URL: http://svn.apache.org/r1515783
Log:
use valid error code (in place of xa_ok) for xaexceptions in the absense of marshalled exception
content from the broker

Modified:
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java?rev=1515783&r1=1515782&r2=1515783&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java
Tue Aug 20 11:21:43 2013
@@ -772,6 +772,11 @@ public class TransactionContext implemen
             XAException original = (XAException)e.getCause();
             XAException xae = new XAException(original.getMessage());
             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);
             return xae;
         }

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java?rev=1515783&r1=1515782&r2=1515783&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ActiveMQXAConnectionFactoryTest.java
Tue Aug 20 11:21:43 2013
@@ -411,12 +411,35 @@ public class ActiveMQXAConnectionFactory
         } 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(
             ActiveMQXAConnection connection1, Xid tid) throws Exception {
 
         FailoverTransport transport = (FailoverTransport) connection1.getTransport().narrow(FailoverTransport.class);
         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));
     }
 



Mime
View raw message