You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2013/11/07 16:23:29 UTC

[1/2] git commit: updated refs/heads/master to f6f4a93

Updated Branches:
  refs/heads/master 3f5b8f706 -> f6f4a9314


Fix CID 1116743 Resource leak


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

Branch: refs/heads/master
Commit: f6f4a9314517023487409ac7cea96adb7b4c0256
Parents: 5cb3cd6
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Nov 7 16:22:53 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Nov 7 16:23:20 2013 +0100

----------------------------------------------------------------------
 .../cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6f4a931/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
index ee00dd5..7b9cf95 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
@@ -203,12 +203,17 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
             rs = pstmt.executeQuery();
             while (rs.next()) {
                 long sid = rs.getLong(1);
-                String rl = rs.getString(2);
                 long snid = rs.getLong(3);
                 return findByStoreSnapshot(role, sid, snid);
             }
         } catch (SQLException e) {
             s_logger.debug("Failed to find parent snapshot: " + e.toString());
+        } finally {
+            try {
+                if (pstmt != null)
+                    pstmt.close();
+            } catch (SQLException e) {
+            }
         }
         return null;
     }


[2/2] git commit: updated refs/heads/master to f6f4a93

Posted by hu...@apache.org.
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 <ht...@schubergphilis.com>
Authored: Thu Nov 7 16:15:34 2013 +0100
Committer: Hugo Trippaers <ht...@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) {