cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject git commit: updated refs/heads/4.4-forward to d511847
Date Tue, 03 Jun 2014 12:10:56 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 67d92726c -> d511847cf


Fixed Resource leak (RESOURCE_LEAK) 11. overwrite_var: Overwriting "pstmt" in "pstmt = conn.prepareStatement("INSERT
INTO `cloud`.`ldap_configuration`(hostname, port) VALUES(?,?)")" leaks the resource that "pstmt"
refers to.

Signed-off-by: Koushik Das <koushik@apache.org>


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

Branch: refs/heads/4.4-forward
Commit: d511847cfedad5478d1b4087c8f97be2c5bf3cc8
Parents: 67d9272
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Tue Jun 3 16:11:01 2014 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Tue Jun 3 17:32:43 2014 +0530

----------------------------------------------------------------------
 engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d511847c/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
index 7e26132..889cad4 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
@@ -130,18 +130,20 @@ public class Upgrade421to430 implements DbUpgrade {
 
         try {
 
+            pstmt = conn.prepareStatement(insertSql);
             for (String[] ldapParam : ldapParams) {
                 String name = ldapParam[0];
                 String value = ldapParam[1];
                 String desc = ldapParam[2];
                 String encryptedValue = DBEncryptionUtil.encrypt(value);
-                pstmt = conn.prepareStatement(insertSql);
                 pstmt.setString(1, name);
                 pstmt.setBytes(2, encryptedValue.getBytes("UTF-8"));
                 pstmt.setString(3, desc);
                 pstmt.executeUpdate();
             }
 
+            pstmt.close();
+
             /**
              * if encrypted, decrypt the ldap hostname and port and then update as they are
not encrypted now.
              */
@@ -154,6 +156,8 @@ public class Upgrade421to430 implements DbUpgrade {
                 hostname = DBEncryptionUtil.decrypt(resultSet.getString(1));
             }
 
+            pstmt.close();
+
             pstmt = conn.prepareStatement("SELECT conf.value FROM `cloud`.`configuration`
conf WHERE conf.name='ldap.port'");
             resultSet = pstmt.executeQuery();
             if (resultSet.next()) {
@@ -162,6 +166,7 @@ public class Upgrade421to430 implements DbUpgrade {
                     portNumber = Integer.valueOf(port);
                 }
             }
+            pstmt.close();
 
             if (StringUtils.isNotBlank(hostname)) {
                 pstmt = conn.prepareStatement("INSERT INTO `cloud`.`ldap_configuration`(hostname,
port) VALUES(?,?)");
@@ -172,6 +177,7 @@ public class Upgrade421to430 implements DbUpgrade {
                     pstmt.setNull(2, Types.INTEGER);
                 }
                 pstmt.executeUpdate();
+                pstmt.close();
             }
 
         } catch (SQLException e) {


Mime
View raw message