[jboss-cvs] JBossAS SVN: r111645 - in projects/jboss-jca/trunk/adapters/src: main/java/org/jboss/jca/adapters/jdbc/util and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 20 15:06:54 EDT 2011
Author: jesper.pedersen
Date: 2011-06-20 15:06:54 -0400 (Mon, 20 Jun 2011)
New Revision: 111645
Added:
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/util/ReentrantLock.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/ConnectionCloseXAResource.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockConnectionHandler.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockDriver.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockTestCase.java
projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/package.html
projects/jboss-jca/trunk/adapters/src/test/resources/deadlock-ds.xml
Modified:
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java
projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrappedConnection.java
Log:
[JBJCA-599] Deadlock in JDBC adapter
Modified: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java 2011-06-20 19:03:57 UTC (rev 111644)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -23,6 +23,7 @@
package org.jboss.jca.adapters.jdbc;
import org.jboss.jca.adapters.jdbc.spi.reauth.ReauthPlugin;
+import org.jboss.jca.adapters.jdbc.util.ReentrantLock;
import java.io.PrintWriter;
import java.sql.CallableStatement;
@@ -39,7 +40,6 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantLock;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
@@ -274,6 +274,32 @@
*/
public void cleanup() throws ResourceException
{
+ boolean isActive = false;
+
+ if (lock.hasQueuedThreads())
+ {
+ Collection<Thread> threads = lock.getQueuedThreads();
+ for (Thread thread : threads)
+ {
+ Throwable t = new Throwable("Thread waiting for lock during cleanup");
+ t.setStackTrace(thread.getStackTrace());
+
+ mcf.log.warn(t.getMessage(), t);
+ }
+
+ isActive = true;
+ }
+
+ if (lock.isLocked())
+ {
+ Throwable t = new Throwable("Lock owned during cleanup");
+ t.setStackTrace(lock.getOwner().getStackTrace());
+
+ mcf.log.warn(t.getMessage(), t);
+
+ isActive = true;
+ }
+
synchronized (handles)
{
for (Iterator<WrappedConnection> i = handles.iterator(); i.hasNext();)
@@ -302,11 +328,17 @@
}
}
}
- // I'm recreating the lock object when we return to the pool
- // because it looks too nasty to expect the connection handle
- // to unlock properly in certain race conditions
- // where the dissociation of the managed connection is "random".
- lock = new ReentrantLock(true);
+
+ if (isActive)
+ {
+ // I'm recreating the lock object when we return to the pool
+ // because it looks too nasty to expect the connection handle
+ // to unlock properly in certain race conditions
+ // where the dissociation of the managed connection is "random".
+ //lock = new ReentrantLock(true);
+
+ throw new ResourceException("Still active locks");
+ }
}
/**
Modified: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrappedConnection.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrappedConnection.java 2011-06-20 19:03:57 UTC (rev 111644)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrappedConnection.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -100,9 +100,17 @@
void setManagedConnection(final BaseWrapperManagedConnection mc)
{
this.mc = mc;
+ this.lockCount = 0;
if (mc != null)
+ {
trackStatements = mc.getTrackStatements();
+ }
+ else
+ {
+ // Reset lockedMC reference once the connection is returned to the pool
+ lockedMC = null;
+ }
}
/**
Added: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/util/ReentrantLock.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/util/ReentrantLock.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/util/ReentrantLock.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.adapters.jdbc.util;
+
+import java.util.Collection;
+
+/**
+ * ReentrantLock override
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class ReentrantLock extends java.util.concurrent.locks.ReentrantLock
+{
+ /** Serial version uid */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor
+ * @param fair Fair locking
+ */
+ public ReentrantLock(boolean fair)
+ {
+ super(fair);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Thread getOwner()
+ {
+ return super.getOwner();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Collection<Thread> getQueuedThreads()
+ {
+ return super.getQueuedThreads();
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/ConnectionCloseXAResource.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/ConnectionCloseXAResource.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/ConnectionCloseXAResource.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.adapters.jdbc.deadlock;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Connection close XAResource
+ */
+class ConnectionCloseXAResource implements XAResource
+{
+ private static Logger log = Logger.getLogger(ConnectionCloseXAResource.class);
+ private Connection connection;
+ private int timeout;
+
+ /**
+ * Constructor
+ * @param connection The connection
+ */
+ public ConnectionCloseXAResource(Connection connection)
+ {
+ this.connection = connection;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit(Xid xid, boolean arg1) throws XAException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void end(Xid xid, int arg1) throws XAException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void forget(Xid xid) throws XAException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getTransactionTimeout() throws XAException
+ {
+ return timeout;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSameRM(XAResource xaResource) throws XAException
+ {
+ return (xaResource == this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int prepare(Xid xid) throws XAException
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Xid[] recover(int flag) throws XAException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback(Xid xid) throws XAException
+ {
+ log.info("Closing connection through rollback");
+ try
+ {
+ connection.close();
+ log.info("Closed connection through rollback");
+ }
+ catch (SQLException se)
+ {
+ log.error("Unexpected error closing exception " + se.getMessage(), se);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean setTransactionTimeout(int timeout) throws XAException
+ {
+ this.timeout = timeout;
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start(Xid xid, int flags) throws XAException
+ {
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockConnectionHandler.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockConnectionHandler.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockConnectionHandler.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.adapters.jdbc.deadlock;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Deadlock connection handler
+ */
+class DeadlockConnectionHandler implements InvocationHandler
+{
+ private static Logger log = Logger.getLogger(DeadlockConnectionHandler.class);
+ private Connection connection;
+
+ /**
+ * Constructor
+ * @param connection The connection
+ */
+ public DeadlockConnectionHandler(Connection connection)
+ {
+ this.connection = connection;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ String methodName = method.getName();
+ if ("createStatement".equals(methodName))
+ {
+ log.info("Forcing deadlock");
+
+ forceDeadlock();
+
+ throw new SQLException("Deadlock should now occur");
+ }
+ else
+ {
+ return method.invoke(connection, args);
+ }
+ }
+
+ private void forceDeadlock() throws SystemException
+ {
+ final TransactionManager tm = getTransactionManager();
+ final Transaction transaction = tm.getTransaction();
+
+ Runnable rollback = new Runnable()
+ {
+ public void run()
+ {
+ log.info("Before rollback");
+ try
+ {
+ transaction.rollback();
+ }
+ catch (Throwable t)
+ {
+ log.info(t.getMessage(), t);
+ }
+ finally
+ {
+ log.info("After rollback");
+ }
+ }
+ };
+
+ Thread thread = new Thread(rollback);
+ thread.start();
+
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException ie)
+ {
+ // Ignore
+ }
+ }
+
+ private TransactionManager getTransactionManager()
+ {
+ Context context = null;
+ try
+ {
+ context = new InitialContext();
+ return (TransactionManager)context.lookup("java:/TransactionManager");
+ }
+ catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ }
+ finally
+ {
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+ }
+
+ return null;
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockDriver.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockDriver.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockDriver.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.adapters.jdbc.deadlock;
+
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * Deadlock JDBC driver
+ */
+public class DeadlockDriver implements Driver
+{
+ private static final String PREFIX = "deadlock:";
+
+ /**
+ * {@inheritDoc}
+ */
+ public Connection connect(String url, Properties info) throws SQLException
+ {
+ if (isOurUrl(url))
+ {
+ Connection connection = DriverManager.getConnection(getUrl(url), info);
+ Connection result =
+ (Connection)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] {Connection.class},
+ new DeadlockConnectionHandler(connection));
+ return result;
+ }
+
+ throw new SQLException("Incorrect url: " + url);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean acceptsURL(String url) throws SQLException
+ {
+ return isOurUrl(url);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
+ {
+ if (isOurUrl(url))
+ {
+ String driverUrl = getUrl(url);
+ Driver driver = DriverManager.getDriver(driverUrl);
+ return driver.getPropertyInfo(driverUrl, info);
+ }
+
+ throw new SQLException("Incorrect url: " + url);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMajorVersion()
+ {
+ return 1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMinorVersion()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean jdbcCompliant()
+ {
+ return true;
+ }
+
+ private boolean isOurUrl(final String url)
+ {
+ return url.startsWith(PREFIX);
+ }
+
+ private String getUrl(final String url)
+ {
+ if (isOurUrl(url))
+ {
+ return url.substring(PREFIX.length());
+ }
+ else
+ {
+ return url;
+ }
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockTestCase.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/DeadlockTestCase.java 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.adapters.jdbc.deadlock;
+
+import org.jboss.jca.embedded.Embedded;
+import org.jboss.jca.embedded.EmbeddedFactory;
+
+import java.net.URL;
+import java.sql.Connection;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.jboss.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests for dead locks
+ */
+public class DeadlockTestCase
+{
+ private static Logger log = Logger.getLogger(DeadlockTestCase.class);
+
+ private static Embedded embedded;
+ private static TransactionManager tm;
+
+ /**
+ * Deadlock with database enabled
+ * @exception Throwable If an error occurs
+ */
+ @Test
+ public void testDeadlockDBEnabled() throws Throwable
+ {
+ Context context = null;
+
+ URL jdbc = DeadlockTestCase.class.getClassLoader().getResource("jdbc-local.rar");
+ URL deadlock = DeadlockTestCase.class.getClassLoader().getResource("deadlock-ds.xml");
+
+ embedded.deploy(jdbc);
+ embedded.deploy(deadlock);
+
+ tm.begin();
+ try
+ {
+ Transaction transaction = tm.getTransaction();
+
+ context = new InitialContext();
+
+ DataSource ds = (DataSource)context.lookup("java:/DeadlockDS");
+ Connection connection = ds.getConnection();
+
+ transaction.enlistResource(new ConnectionCloseXAResource(connection));
+
+ // Now trigger everything.
+ connection.createStatement();
+ }
+ catch (Throwable t)
+ {
+ log.info("Throwable during testDeadlockDBEnabled: " + t.getMessage(), t);
+ }
+ finally
+ {
+ log.info("Rolling back in testDeadlockDBEnabled");
+ try
+ {
+ tm.rollback();
+ }
+ finally
+ {
+ log.info("Completed rollback in testDeadlockDBEnabled");
+ }
+
+ embedded.undeploy(deadlock);
+ embedded.undeploy(jdbc);
+ }
+ }
+
+ /**
+ * Deadlock with database disabled
+ * @exception Throwable If an error occurs
+ */
+ @Test
+ public void testDeadlockDBDisabled() throws Throwable
+ {
+ Context context = null;
+
+ URL jdbc = DeadlockTestCase.class.getClassLoader().getResource("jdbc-local.rar");
+ URL deadlock = DeadlockTestCase.class.getClassLoader().getResource("deadlock-ds.xml");
+
+ embedded.deploy(jdbc);
+ embedded.deploy(deadlock);
+
+ tm.begin();
+ try
+ {
+ Transaction transaction = tm.getTransaction();
+
+ context = new InitialContext();
+
+ DataSource ds = (DataSource)context.lookup("java:/DeadlockDS");
+ Connection connection = ds.getConnection();
+
+ transaction.enlistResource(new ConnectionCloseXAResource(connection));
+
+ embedded.undeploy(deadlock);
+
+ // Now trigger everything.
+ connection.createStatement();
+ }
+ catch (Throwable t)
+ {
+ log.info("Throwable during testDeadlockDBDisabled: " + t.getMessage(), t);
+ }
+ finally
+ {
+ log.info("Rolling back in testDeadlockDBDisabled");
+ try
+ {
+ tm.rollback();
+ }
+ finally
+ {
+ log.info("Completed rollback in testDeadlockDBDisabled");
+ }
+
+ embedded.undeploy(jdbc);
+ }
+ }
+
+ /**
+ * Lifecycle start, before the suite is executed
+ * @throws Throwable throwable exception
+ */
+ @BeforeClass
+ public static void before() throws Throwable
+ {
+ // Create and set an embedded JCA instance
+ embedded = EmbeddedFactory.create();
+
+ // Startup
+ embedded.startup();
+
+ // Transaction Manager
+ tm = embedded.lookup("RealTransactionManager", TransactionManager.class);
+ }
+
+ /**
+ * Lifecycle stop, after the suite is executed
+ * @throws Throwable throwable exception
+ */
+ @AfterClass
+ public static void after() throws Throwable
+ {
+ // Reset TM reference
+ tm = null;
+
+ // Shutdown embedded
+ embedded.shutdown();
+
+ // Set embedded to null
+ embedded = null;
+ }
+}
Added: projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/package.html
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/package.html (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/java/org/jboss/jca/adapters/jdbc/deadlock/package.html 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,3 @@
+<body>
+This package contains test cases for detecting dead lock issues in the JDBC resource adapter.
+</body>
Added: projects/jboss-jca/trunk/adapters/src/test/resources/deadlock-ds.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/src/test/resources/deadlock-ds.xml (rev 0)
+++ projects/jboss-jca/trunk/adapters/src/test/resources/deadlock-ds.xml 2011-06-20 19:06:54 UTC (rev 111645)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+
+ <datasource jndi-name="java:/DeadlockDS" pool-name="DeadlockDS">
+ <connection-url>deadlock:jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+ <driver-class>org.jboss.jca.adapters.jdbc.deadlock.DeadlockDriver</driver-class>
+ <security>
+ <user-name>sa</user-name>
+ <password>sa</password>
+ </security>
+ </datasource>
+
+</datasources>
More information about the jboss-cvs-commits
mailing list