cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [2/2] git commit: updated refs/heads/master to f6f4a93
Date Thu, 07 Nov 2013 15:23:30 GMT
Fix CID 1116741,1116742 Resource leak


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5cb3cd64
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5cb3cd64
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5cb3cd64

Branch: refs/heads/master
Commit: 5cb3cd64e5661b55fca2f22f6bfc77b84f35ab13
Parents: 3f5b8f7
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Thu Nov 7 16:15:34 2013 +0100
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Thu Nov 7 16:23:20 2013 +0100

----------------------------------------------------------------------
 .../config/dao/ConfigurationDaoImpl.java        | 26 ++++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5cb3cd64/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java
b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java
index 8804740..2934b01 100644
--- a/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java
+++ b/framework/config/src/org/apache/cloudstack/framework/config/dao/ConfigurationDaoImpl.java
@@ -17,6 +17,7 @@
 package org.apache.cloudstack.framework.config.dao;
 
 import java.sql.PreparedStatement;
+import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -26,9 +27,10 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
-import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
 import org.springframework.stereotype.Component;
 
+import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
+
 import com.cloud.utils.component.ComponentLifecycle;
 import com.cloud.utils.crypt.DBEncryptionUtil;
 import com.cloud.utils.db.DB;
@@ -142,14 +144,21 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO,
String
     @Deprecated
     public boolean update(String name, String value) {
         TransactionLegacy txn = TransactionLegacy.currentTxn();
+        PreparedStatement stmt = null;
         try {
-            PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
+            stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
             stmt.setString(1, value);
             stmt.setString(2, name);
             stmt.executeUpdate();
             return true;
         } catch (Exception e) {
             s_logger.warn("Unable to update Configuration Value", e);
+        } finally {
+            try {
+                if (stmt != null)
+                    stmt.close();
+            } catch (SQLException e) {
+            }
         }
         return false;
     }
@@ -157,15 +166,22 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO,
String
     @Override
     public boolean update(String name, String category, String value) {
         TransactionLegacy txn = TransactionLegacy.currentTxn();
+        PreparedStatement stmt = null;
         try {
             value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value)
: value;
-            PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
+            stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
             stmt.setString(1, value);
             stmt.setString(2, name);
             stmt.executeUpdate();
             return true;
         } catch (Exception e) {
             s_logger.warn("Unable to update Configuration Value", e);
+        } finally {
+            try {
+                if (stmt != null)
+                    stmt.close();
+            } catch (SQLException e) {
+            }
         }
         return false;
     }
@@ -178,9 +194,9 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO,
String
 
     @Override
     public String getValueAndInitIfNotExist(String name, String category, String initValue)
{
-    	return getValueAndInitIfNotExist(name, category, initValue, ""); 
+        return getValueAndInitIfNotExist(name, category, initValue, "");
     }
-    
+
     @Override
     @DB
     public String getValueAndInitIfNotExist(String name, String category, String initValue,
String desc) {


Mime
View raw message