details:   https://code.openbravo.com/erp/devel/pi/rev/a844ff835130
changeset: 15937:a844ff835130
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Thu Mar 29 11:19:23 2012 +0200
summary:   fixed bug 20146: AlertActionHandler PreparedStatement is not closed

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
 |  19 ++++++++-
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r 9a9b791783b1 -r a844ff835130 
modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
     Thu Mar 29 07:55:48 2012 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java
     Thu Mar 29 11:19:23 2012 +0200
@@ -104,12 +104,13 @@
             + OBDal.getInstance().getReadableOrganizationsInClause()
             + " AND AD_ALERTRULE_ID = ? " + (whereClause == null ? "" : 
whereClause);
 
+        PreparedStatement sqlQuery = null;
+        ResultSet rs = null;
         try {
-          final PreparedStatement sqlQuery = new DalConnectionProvider(false)
-              .getPreparedStatement(sql);
+          sqlQuery = new 
DalConnectionProvider(false).getPreparedStatement(sql);
           sqlQuery.setString(1, alertRule.getId());
           sqlQuery.execute();
-          ResultSet rs = sqlQuery.getResultSet();
+          rs = sqlQuery.getResultSet();
           if (rs.next()) {
             long rows = rs.getLong(1);
             total += rs.getLong(1);
@@ -119,6 +120,18 @@
         } catch (Exception e) {
           log4j.error("An error has ocurred when trying to process the alerts: 
" + e.getMessage(),
               e);
+        } finally {
+          try {
+            if (sqlQuery != null) {
+              sqlQuery.close();
+            }
+            if (rs != null) {
+              rs.close();
+            }
+          } catch (Exception e) {
+            log4j.error(
+                "An error has ocurred when trying to close the statement: " + 
e.getMessage(), e);
+          }
         }
       }
 

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to