-
Bug
-
Resolution: Obsolete
-
Major
-
JBossAS-4.0.0 Final
-
None
SourceForge Submitter: cmunday .
Hi,
There is a Statement that does not get closed and is
left to be finialized within the following method (included
below) from the HiLoKeyGenerator class.
The statement create by:
stmt = con.prepareStatement(nextKeyQuery);
leaks because the variable "stmt" is re-assigned with:
stmt = con.prepareStatement(updateStmt);
This second statement is closed within the finally clause
but the first one is never closed and should be
Cheers,
Craig.
public synchronized Object generateKey()
{
if(lo < hi)
return new Integer(lo++);
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Transaction currentTx = null;
try
{
currentTx = tm.suspend();
tm.begin();
con = datasource.getConnection();
int rowsUpdated;
do
while(rowsUpdated == 0);
tm.commit();
}
catch(Exception e)
{
log.error("Error fetching next key:", e);
try
catch(SystemException se)
{ log.error("Couldn't rollback transaction: ", se); } }
finally
{
JDBCUtil.safeClose(rs);
JDBCUtil.safeClose(stmt);
JDBCUtil.safeClose(con);
if(currentTx != null)
{
try
catch(InvalidTransactionException ite)
{ log.error("Invalid transaction: ", ite); }catch(SystemException se)
{ log.error("Unexpected error: ", se); } }
}
return new Integer(lo++);
}