[ 1874419 ] JDBC Statement not close in a finally block

This commit is contained in:
Heng Sin Low 2008-01-29 08:47:47 +00:00
parent 6a71c3de64
commit 860b4ede1e
5 changed files with 69 additions and 103 deletions

View File

@ -129,23 +129,16 @@ public class AcctProcessor extends AdempiereServer
countError++;
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
if (pstmt != null)
finally
{
try
{
pstmt.close();
}
catch (Exception e)
{
}
DB.close(pstmt);
}
//
if (count > 0)
{

View File

@ -270,20 +270,17 @@ public class AlertProcessor extends AdempiereServer
pstmt.close ();
pstmt = null;
}
catch (Exception e)
catch (Throwable e)
{
log.log(Level.SEVERE, sql, e);
error = e;
if (e instanceof Exception)
error = (Exception)e;
else
error = new Exception(e.getMessage(), e);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(pstmt);
}
// Error occured

View File

@ -116,13 +116,15 @@ public class RequestProcessor extends AdempiereServer
}
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("New Due #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
@ -169,13 +171,15 @@ public class RequestProcessor extends AdempiereServer
}
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("New Overdue #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
@ -224,12 +228,15 @@ public class RequestProcessor extends AdempiereServer
count++;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("Alerts #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
@ -265,12 +272,15 @@ public class RequestProcessor extends AdempiereServer
count++;
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("Escalated #").append(count).append(" - ");
} // Esacalate
@ -316,29 +326,20 @@ public class RequestProcessor extends AdempiereServer
}
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("Inactivity #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
m_summary.append (" - ");
} // Inactivity
//
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
} // Inactivity
} // processRequests
/**
@ -442,22 +443,14 @@ public class RequestProcessor extends AdempiereServer
count++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(pstmt);
}
m_summary.append("Status Timeout #").append(count)
@ -506,23 +499,16 @@ public class RequestProcessor extends AdempiereServer
failure++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(pstmt);
}
m_summary.append("Auto Change Request #").append(count);
if (failure > 0)
m_summary.append("(fail=").append(failure).append(")");
@ -578,20 +564,14 @@ public class RequestProcessor extends AdempiereServer
notFound++;
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (SQLException ex)
{
log.log(Level.SEVERE, sql, ex);
}
try
{
if (pstmt != null)
pstmt.close();
}
catch (SQLException ex1)
finally
{
DB.close(pstmt);
}
pstmt = null;
//

View File

@ -77,8 +77,12 @@ public class Scheduler extends AdempiereServer
log.log(Level.WARNING, process.toString(), e);
m_summary.append(e.toString());
}
if (m_trx != null)
m_trx.close();
finally
{
if (m_trx != null)
m_trx.close();
}
//
int no = m_model.deleteLog();
m_summary.append("Logs deleted=").append(no);

View File

@ -104,14 +104,16 @@ public class WorkflowProcessor extends AdempiereServer
// saves and calls MWFProcess.checkActivities();
count++;
}
rs.close ();
pstmt.close ();
pstmt = null;
rs.close ();
}
catch (Exception e)
{
log.log(Level.SEVERE, "wakeup", e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("Wakeup #").append(count).append (" - ");
} // wakeup
@ -149,26 +151,17 @@ public class WorkflowProcessor extends AdempiereServer
count++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
m_summary.append("DynPriority #").append(count).append (" - ");
// Clean-up
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(pstmt);
}
m_summary.append("DynPriority #").append(count).append (" - ");
} // setPriority
@ -194,9 +187,10 @@ public class WorkflowProcessor extends AdempiereServer
+ " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))";
int count = 0;
int countEMails = 0;
PreparedStatement pstmt = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt (1, m_model.getAlertOverPriority());
pstmt.setInt (2, m_model.getAD_WorkflowProcessor_ID());
ResultSet rs = pstmt.executeQuery();
@ -217,6 +211,10 @@ public class WorkflowProcessor extends AdempiereServer
{
log.log(Level.SEVERE, "(Priority) - " + sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("OverPriority #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
@ -258,13 +256,16 @@ public class WorkflowProcessor extends AdempiereServer
count++;
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log(Level.SEVERE, "(EndWaitTime) - " + sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("EndWaitTime #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
@ -311,24 +312,15 @@ public class WorkflowProcessor extends AdempiereServer
{
log.log(Level.SEVERE, "(Inactivity): " + sql, e);
}
finally
{
DB.close(pstmt);
}
m_summary.append("Inactivity #").append(count);
if (countEMails > 0)
m_summary.append(" (").append(countEMails).append(" EMail)");
m_summary.append (" - ");
} // Inactivity
// Clean-up
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
} // Inactivity
} // sendAlerts
/**