cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [6/8] git commit: updated refs/heads/master to 8151f7f
Date Mon, 03 Aug 2015 19:57:32 GMT
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 <daan.hoogland@gmail.com>
Authored: Tue Jul 28 17:23:44 2015 +0200
Committer: Daan Hoogland <daan.hoogland@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();
+        }
     }
 }


Mime
View raw message