You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2015/08/03 21:57:32 UTC
[6/8] git commit: updated refs/heads/master to 8151f7f
coverity 1116562: resource count resource leak
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/16819936
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/16819936
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/16819936
Branch: refs/heads/master
Commit: 168199360d45657c9752237e3aa208df79bbdc0b
Parents: 49cb56b
Author: Daan Hoogland <da...@gmail.com>
Authored: Tue Jul 28 17:23:44 2015 +0200
Committer: Daan Hoogland <da...@gmail.com>
Committed: Tue Jul 28 17:23:44 2015 +0200
----------------------------------------------------------------------
.../src/com/cloud/upgrade/dao/Upgrade420to421.java | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16819936/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
index 1928552..66c1a2e 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
@@ -280,14 +280,13 @@ public class Upgrade420to421 implements DbUpgrade {
private static void upgradeResourceCountforDomain(Connection conn, Long domainId, String type, Long resourceCount) throws SQLException {
//update or insert into resource_count table.
- PreparedStatement pstmt = null;
- pstmt =
- conn.prepareStatement("INSERT INTO `cloud`.`resource_count` (domain_id, type, count) VALUES (?,?,?) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), count=?");
- pstmt.setLong(1, domainId);
- pstmt.setString(2, type);
- pstmt.setLong(3, resourceCount);
- pstmt.setLong(4, resourceCount);
- pstmt.executeUpdate();
- pstmt.close();
+ String sqlInsertResourceCount = "INSERT INTO `cloud`.`resource_count` (domain_id, type, count) VALUES (?,?,?) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), count=?";
+ try (PreparedStatement pstmt = conn.prepareStatement(sqlInsertResourceCount);) {
+ pstmt.setLong(1, domainId);
+ pstmt.setString(2, type);
+ pstmt.setLong(3, resourceCount);
+ pstmt.setLong(4, resourceCount);
+ pstmt.executeUpdate();
+ }
}
}