You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ko...@apache.org on 2014/06/03 14:10:56 UTC
git commit: updated refs/heads/4.4-forward to d511847
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 <ko...@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 <ra...@gmail.com>
Authored: Tue Jun 3 16:11:01 2014 +0530
Committer: Koushik Das <ko...@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) {