[Jboss-cvs] JBossAS SVN: r55017 - branches/Branch_4_0/testsuite/src/main/org/jboss/test/jca/adapter
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 1 23:42:16 EDT 2006
Author: weston.price at jboss.com
Date: 2006-08-01 23:42:16 -0400 (Tue, 01 Aug 2006)
New Revision: 55017
Modified:
branches/Branch_4_0/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java
Log:
[JBAS-3336]Destroy a connection where XA enlistment fails and do not return the
connection to the pool. Unit test support.
Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java 2006-08-02 03:39:08 UTC (rev 55016)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java 2006-08-02 03:42:16 UTC (rev 55017)
@@ -35,6 +35,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;
@@ -77,16 +78,23 @@
private boolean failInPrepare = false;
private boolean failInCommit = false;
- private int xaCode;
+ private static boolean failInStart = false;
+ private static int xaCode;
+
private String localState = LOCAL_NONE;
+ public static void setFailInStart(boolean fis, int xa)
+ {
+ failInStart = fis;
+ xaCode = xa;
+ }
public TestManagedConnection (final TestManagedConnectionFactory mcf, final Subject subject, final TestConnectionRequestInfo cri, final int id)
{
this.mcf = mcf;
this.id = id;
}
-
+
void setFailInPrepare(final boolean fail, final int xaCode)
{
this.failInPrepare = fail;
@@ -203,6 +211,13 @@
synchronized (this)
{
+ if(failInStart)
+ {
+ XAException xaex = new XAException(xaCode + "for" + this);
+ broadcastConnectionError(xaex);
+ throw new XAException(xaCode + "for" + this);
+ }
+
GlobalXID gid = new GlobalXID(xid);
String flagString = TxUtils.getXAResourceFlagsAsString(flags);
log.info("start with xid=" + gid + " flags=" + flagString + " for " + this);
@@ -467,6 +482,35 @@
}
}
+ protected void broadcastConnectionError(Throwable e)
+ {
+ if(destroyed.get())
+ return;
+
+ Exception ex = null;
+ if (e instanceof Exception)
+ ex = (Exception) e;
+ else
+ ex = new ResourceAdapterInternalException("Unexpected error", e);
+ 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)
+ {
+ }
+ }
+ }
+
void connectionError(TestConnection handle, Exception e)
{
if (destroyed.get())
More information about the jboss-cvs-commits
mailing list