[jboss-cvs] JBoss Messaging SVN: r1680 - branches/Branch_1_0_XARecovery/src/main/org/jboss/jms/tx

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 1 21:26:37 EST 2006


Author: juha at jboss.org
Date: 2006-12-01 21:26:36 -0500 (Fri, 01 Dec 2006)
New Revision: 1680

Modified:
   branches/Branch_1_0_XARecovery/src/main/org/jboss/jms/tx/MessagingXAResource.java
Log:
disallow foreign xid implementations (JBMESSAGING-661)

Modified: branches/Branch_1_0_XARecovery/src/main/org/jboss/jms/tx/MessagingXAResource.java
===================================================================
--- branches/Branch_1_0_XARecovery/src/main/org/jboss/jms/tx/MessagingXAResource.java	2006-12-02 02:25:06 UTC (rev 1679)
+++ branches/Branch_1_0_XARecovery/src/main/org/jboss/jms/tx/MessagingXAResource.java	2006-12-02 02:26:36 UTC (rev 1680)
@@ -28,6 +28,7 @@
 import org.jboss.jms.client.state.SessionState;
 import org.jboss.jms.delegate.ConnectionDelegate;
 import org.jboss.logging.Logger;
+import org.jboss.messaging.core.tx.XidImpl;
 
 /**
  * An XAResource implementation.
@@ -38,6 +39,7 @@
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
  * 
  * Parts based on JBoss MQ XAResource implementation by:
  * 
@@ -112,7 +114,12 @@
    public void commit(Xid xid, boolean onePhase) throws XAException
    {
       if (trace) { log.trace(this + " committing " + xid + (onePhase ? " (one phase)" : " (two phase)")); }
-      
+
+      // Recreate Xid. See JBMESSAGING-661 [JPL]
+
+      if (!(xid instanceof XidImpl))
+         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+
       rm.commit(xid, onePhase, connection);
 
       // leave the session in a 'clean' state, the currentTxId will be set when the XAResource will
@@ -125,6 +132,11 @@
    {
       if (trace) { log.trace(this + " ending " + xid + ", flags: " + flags); }
 
+      // Recreate Xid. See JBMESSAGING-661 [JPL]
+
+      if (!(xid instanceof XidImpl))
+         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+
       synchronized (this)
       {
          switch (flags)
@@ -148,11 +160,22 @@
    public void forget(Xid xid) throws XAException
    {
       if (trace) { log.trace(this + " forgetting " + xid + " (currently an NOOP)"); }
+
+      // Recreate Xid. See JBMESSAGING-661 [JPL]
+
+      if (!(xid instanceof XidImpl))
+         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
    }
 
    public int prepare(Xid xid) throws XAException
    {
       if (trace) { log.trace(this + " preparing " + xid); }
+
+      // Recreate Xid. See JBMESSAGING-661 [JPL]
+
+      if (!(xid instanceof XidImpl))
+         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+
       return rm.prepare(xid, connection);
    }
 
@@ -167,6 +190,11 @@
    {
       if (trace) { log.trace(this + " rolling back " + xid); }
 
+      // Recreate Xid. See JBMESSAGING-661 [JPL]
+
+      if (!(xid instanceof XidImpl))
+         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+
       // TODO Hmmm on rollback should we also stop and start the consumers to remove any transient
       // messages, like we do on local session rollback??
       
@@ -177,6 +205,11 @@
    {
       if (trace) { log.trace(this + " starting " + xid + ", flags: " + flags); }
       
+      // Recreate Xid. See JBMESSAGING-661 [JPL]
+
+      if (!(xid instanceof XidImpl))
+         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+
       boolean convertTx = false;
       
       if (sessionState.getCurrentTxId() != null)




More information about the jboss-cvs-commits mailing list