[Jboss-cvs] JBossAS SVN: r55961 - branches/JBoss_3_2_8_SP1_JBAS_3336/testsuite/src/main/org/jboss/test/jca/adapter
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 15 11:56:38 EDT 2006
Author: weston.price at jboss.com
Date: 2006-08-15 11:56:37 -0400 (Tue, 15 Aug 2006)
New Revision: 55961
Modified:
branches/JBoss_3_2_8_SP1_JBAS_3336/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java
Log:
[JBAS-3336] Backport of fix for destoying a managed connection in the case of an
error in start() on XA resource.
Modified: branches/JBoss_3_2_8_SP1_JBAS_3336/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java
===================================================================
--- branches/JBoss_3_2_8_SP1_JBAS_3336/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java 2006-08-15 15:56:21 UTC (rev 55960)
+++ branches/JBoss_3_2_8_SP1_JBAS_3336/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java 2006-08-15 15:56:37 UTC (rev 55961)
@@ -34,6 +34,7 @@
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionMetaData;
+import javax.resource.spi.ResourceAdapterInternalException;
import javax.security.auth.Subject;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
@@ -69,7 +70,8 @@
private boolean failInPrepare = false;
private boolean failInCommit = false;
- private int xaCode;
+ private static boolean failInStart = false;
+ private static int xaCode;
public TestManagedConnection (final Subject subject, final TestConnectionRequestInfo cri, final int id)
{
@@ -229,7 +231,40 @@
}
// implementation of javax.transaction.xa.XAResource interface
-
+
+ public static void setFailInStart(boolean fis, int xa)
+ {
+ failInStart = fis;
+ xaCode = xa;
+ }
+ protected void broadcastConnectionError(Throwable e)
+ {
+ if(destroyed)
+ return;
+
+ Exception ex = null;
+ if (e instanceof Exception)
+ ex = (Exception) e;
+ else
+ ex = new ResourceAdapterInternalException("Unexpected error");
+ ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, ex);
+ Collection copy = null;
+ synchronized(listeners)
+ {
+ copy = new ArrayList(listeners);
+ }
+ for (Iterator i = copy.iterator(); i.hasNext(); )
+ {
+ ConnectionEventListener cel = (ConnectionEventListener)i.next();
+ try
+ {
+ cel.connectionErrorOccurred(ce);
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
/**
*
* @param param1 <description>
@@ -238,6 +273,16 @@
*/
public void start(Xid xid, int flags) throws XAException
{
+ synchronized (this)
+ {
+ if(failInStart)
+ {
+ XAException xaex = new XAException(xaCode + "for" + this);
+ broadcastConnectionError(xaex);
+ throw new XAException(xaCode + "for" + this);
+ }
+
+ }
log.info("start with xid " + xid + ", flags " + flags);
this.xid = xid;
}
More information about the jboss-cvs-commits
mailing list