*BF [ 1874419 ] JDBC Statement not close in a finally block

*Organize imports

*Comment Never Used variable
This commit is contained in:
Redhuan D. Oon 2008-02-08 10:20:30 +00:00
parent 8ebf127df3
commit 918872fd8a
1 changed files with 27 additions and 20 deletions

View File

@ -16,12 +16,22 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.wf; package org.compiere.wf;
import java.sql.*; import java.sql.PreparedStatement;
import java.util.*; import java.sql.ResultSet;
import java.util.logging.*; import java.util.ArrayList;
import org.compiere.model.*; import java.util.Properties;
import org.compiere.process.*; import java.util.logging.Level;
import org.compiere.util.*;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.model.X_AD_WF_Process;
import org.compiere.process.DocAction;
import org.compiere.process.ProcessInfo;
import org.compiere.process.StateEngine;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.TimeUtil;
/** /**
@ -70,7 +80,7 @@ public class MWFProcess extends X_AD_WF_Process
if (!TimeUtil.isValid(wf.getValidFrom(), wf.getValidTo())) if (!TimeUtil.isValid(wf.getValidFrom(), wf.getValidTo()))
throw new IllegalStateException("Workflow not valid"); throw new IllegalStateException("Workflow not valid");
m_wf = wf; m_wf = wf;
m_pi = pi; //TODO m_pi = pi; red1 - never used -check later
setAD_Workflow_ID (wf.getAD_Workflow_ID()); setAD_Workflow_ID (wf.getAD_Workflow_ID());
setPriority(wf.getPriority()); setPriority(wf.getPriority());
super.setWFState (WFSTATE_NotStarted); super.setWFState (WFSTATE_NotStarted);
@ -107,7 +117,10 @@ public class MWFProcess extends X_AD_WF_Process
/** Workflow */ /** Workflow */
private MWorkflow m_wf = null; private MWorkflow m_wf = null;
/** Process Info */ /** Process Info */
/*TODO red1 - never used
*
private ProcessInfo m_pi = null; private ProcessInfo m_pi = null;
*/
/** Persistent Object */ /** Persistent Object */
private PO m_po = null; private PO m_po = null;
/** Message from Activity */ /** Message from Activity */
@ -126,6 +139,7 @@ public class MWFProcess extends X_AD_WF_Process
// //
ArrayList<MWFActivity> list = new ArrayList<MWFActivity>(); ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM AD_WF_Activity WHERE AD_WF_Process_ID=?"; String sql = "SELECT * FROM AD_WF_Activity WHERE AD_WF_Process_ID=?";
if (onlyActive) if (onlyActive)
sql += " AND Processed='N'"; sql += " AND Processed='N'";
@ -133,27 +147,20 @@ public class MWFProcess extends X_AD_WF_Process
{ {
pstmt = DB.prepareStatement (sql, get_TrxName()); pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getAD_WF_Process_ID()); pstmt.setInt (1, getAD_WF_Process_ID());
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
while (rs.next ()) while (rs.next ())
list.add (new MWFActivity(getCtx(), rs, get_TrxName())); list.add (new MWFActivity(getCtx(), rs, get_TrxName()));
rs.close (); }
pstmt.close ();
pstmt = null;
}
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close (); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
m_activities = new MWFActivity[list.size ()]; m_activities = new MWFActivity[list.size ()];
list.toArray (m_activities); list.toArray (m_activities);
return m_activities; return m_activities;