[
http://jira.jboss.com/jira/browse/JBAS-4667?page=comments#action_12375405 ]
Adrian Brock commented on JBAS-4667:
------------------------------------
Ok. But that sounds like an example of "bad" caching, the connection handle
usage isn't tied to the EJB invocations so the appserver is going to get confused in
some circumstances.
Anyway, I just reproduced the problem with an SFSB
// Cache the connection in the SFSB state
private Connection c;
public void open() throws RemoteException
{
try
{
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/DefaultDS");
c = ds.getConnection();
}
catch (Exception e)
{
throw new RemoteException("Error", e);
}
}
public void close() throws RemoteException
{
try
{
if (c != null)
c.close();
}
catch (Exception e)
{
throw new RemoteException("Error", e);
}
}
Then the client starts a user transaction and sets rollback only between the invocations
UserTransaction ut = (UserTransaction) ctx.lookup("UserTransaction");
ut.begin();
try
{
StatefulSessionHome home = (StatefulSessionHome)
ctx.lookup("StatefulSessionBean");
StatefulSession session = home.create();
try
{
session.open();
ut.setRollbackOnly();
session.close();
}
finally
{
session.remove();
}
}
finally
{
ut.rollback();
}
Wrong logic in
CachedConnectionManager.getCloseConnectionSynchronization()
--------------------------------------------------------------------------
Key: JBAS-4667
URL:
http://jira.jboss.com/jira/browse/JBAS-4667
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: JCA service
Affects Versions: JBossAS-4.0.4.GA, JBossAS-4.2.1.GA
Reporter: Oleg Nitz
Assigned To: Adrian Brock
Fix For: JBossAS-5.0.0.Beta3, JBossAS-4.2.2.GA
If the tx is not active (for example it has STATUS_PREPARING), then the method always
returns null, even if the associated CloseConnectionSynchronization exists.
This results in wrong warnings about non-closed connections, since when the close() is
called for a connector, in CachedConnectionManager.unregisterConnection() a null value is
returned from getCloseConnectionSynchronization() and the connector remains in the list of
non-closed resources for the transaction.
I think this bug was introduced here:
http://jira.jboss.com/jira/browse/JBAS-31#action_12310798
I propose the following solution:
--- CachedConnectionManager.java.orig 2005-11-22 02:10:41.000000000 +0200
+++ CachedConnectionManager.java 2007-09-04 18:42:48.000000000 +0300
@@ -544,13 +544,13 @@
try
{
Transaction tx = tm.getTransaction();
- if (TxUtils.isActive(tx))
+ if (tx != null)
{
TransactionSynchronizer.lock(tx);
try
{
CloseConnectionSynchronization cas = (CloseConnectionSynchronization)
TransactionSynchronizer.getCCMSynchronization(tx);
- if (cas == null && createIfNotFound)
+ if (cas == null && createIfNotFound &&
TxUtils.isActive(tx))
{
cas = new CloseConnectionSynchronization();
TransactionSynchronizer.registerCCMSynchronization(tx, cas);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira