[jboss-cvs] JBossAS SVN: r110136 - in branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter: jms and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 22 09:31:26 EST 2010
Author: kevin.conner at jboss.com
Date: 2010-12-22 09:31:25 -0500 (Wed, 22 Dec 2010)
New Revision: 110136
Modified:
branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java
branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedConnection.java
branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java
branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java
Log:
incorporate revisions 110058 and 110066 of JBPAPP_5_1: JBPAPP-5596
Modified: branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java
===================================================================
--- branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java 2010-12-22 14:26:48 UTC (rev 110135)
+++ branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java 2010-12-22 14:31:25 UTC (rev 110136)
@@ -75,7 +75,7 @@
private final boolean readOnly;
- private ReentrantLock lock = new ReentrantLock();
+ private ReentrantLock lock = new ReentrantLock(true);
private final Collection cels = new ArrayList();
@@ -245,7 +245,7 @@
// 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();
+ lock = new ReentrantLock(true);
}
protected void lock()
@@ -274,7 +274,8 @@
protected void unlock()
{
- lock.unlock();
+ if (lock.isHeldByCurrentThread())
+ lock.unlock();
}
public Object getConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException
Modified: branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedConnection.java
===================================================================
--- branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedConnection.java 2010-12-22 14:26:48 UTC (rev 110135)
+++ branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jdbc/WrappedConnection.java 2010-12-22 14:31:25 UTC (rev 110136)
@@ -49,7 +49,9 @@
{
private static final Logger log = Logger.getLogger(WrappedConnection.class);
- private BaseWrapperManagedConnection mc;
+ private volatile BaseWrapperManagedConnection mc;
+ private BaseWrapperManagedConnection lockedMC;
+ private int lockCount;
private WrapperDataSource dataSource;
@@ -77,18 +79,25 @@
{
BaseWrapperManagedConnection mc = this.mc;
if (mc != null)
+ {
mc.tryLock();
+ if (lockedMC == null)
+ lockedMC = mc ;
+
+ lockCount++;
+ }
else
throw new SQLException("Connection is not associated with a managed connection." + this);
}
protected void unlock()
{
- BaseWrapperManagedConnection mc = this.mc;
+ BaseWrapperManagedConnection mc = lockedMC;
+ if (--lockCount == 0)
+ lockedMC = null;
+
if (mc != null)
mc.unlock();
- // We recreate the lock when returned to the pool
- // so missing the unlock after disassociation is not important
}
public WrapperDataSource getDataSource()
Modified: branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java
===================================================================
--- branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java 2010-12-22 14:26:48 UTC (rev 110135)
+++ branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsManagedConnection.java 2010-12-22 14:31:25 UTC (rev 110136)
@@ -144,7 +144,7 @@
private String pwd;
private boolean isDestroyed;
- private ReentrantLock lock = new ReentrantLock();
+ private ReentrantLock lock = new ReentrantLock(true);
// Physical JMS connection stuff
private Connection con;
@@ -359,7 +359,7 @@
// 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();
+ lock = new ReentrantLock(true);
}
/**
@@ -414,7 +414,8 @@
protected void unlock()
{
- lock.unlock();
+ if (lock.isHeldByCurrentThread())
+ lock.unlock();
}
/**
Modified: branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java
===================================================================
--- branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java 2010-12-22 14:26:48 UTC (rev 110135)
+++ branches/JBPAPP_5_0_1_GA_JBPAPP-5654/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java 2010-12-22 14:31:25 UTC (rev 110136)
@@ -68,7 +68,9 @@
private static final Logger log = Logger.getLogger(JmsSession.class);
/** The managed connection for this session. */
- private JmsManagedConnection mc; // = null;
+ private volatile JmsManagedConnection mc;
+ private JmsManagedConnection lockedMC;
+ private int lockCount;
/** The connection request info */
private JmsConnectionRequestInfo info;
@@ -107,7 +109,14 @@
{
JmsManagedConnection mc = this.mc;
if (mc != null)
+ {
mc.tryLock();
+
+ if (lockedMC == null)
+ lockedMC = mc;
+
+ lockCount++;
+ }
else
throw new IllegalStateException("Connection is not associated with a managed connection. " + this);
}
@@ -115,10 +124,11 @@
protected void unlock()
{
JmsManagedConnection mc = this.mc;
+ if (--lockCount == 0)
+ lockedMC = null;
+
if (mc != null)
mc.unlock();
- // We recreate the lock when returned to the pool
- // so missing the unlock after disassociation is not important
}
/**
More information about the jboss-cvs-commits
mailing list