Subject destroyDbHandle()
Author J.A.C.K.
Hello again,

This method is taken from FBManagedConnectionFactory.java

void destroyDbHandle(isc_db_handle db, FBConnectionRequestInfo
cri)
{
Collection transactions = db.getTransactions();
Set xidTrs = xidMap.entrySet();
for (Iterator i = transactions.iterator(); i.hasNext();)
{
isc_tr_handle tr = (isc_tr_handle)i.next();
for (Iterator j = xidTrs.iterator(); j.hasNext(); )
{
Map.Entry pair = (Map.Entry)j.next();
if (pair.getValue() == tr)
{
rolledback.add(pair.getKey());
j.remove();
} // end of if ()
} // end of for ()

try
{
gds.isc_rollback_transaction(tr);
}
catch (GDSException ge)
{
if (log!=null) log.debug("exception rolling back
transaction from dying connection: " + ge.getMessage());
} // end of try-catch

} // end of for ()
try
{
releaseDbHandle(db, cri);
}
catch (GDSException ge)
{
if (log!=null) log.debug("exception releasing db handle
from dying connection: " + ge.getMessage());
} // end of try-catch

}


Under a multithreaded environment, if this method is called by one
thread and then concurrently, another method tries to do xidMap.put
(xid,tr) , say from getCurrentIscTrHandle(...,...) , that j.remove()
could possibly throw ConcurrentModificationException. Correct me if
i'm wrong.

Thanks in advance.