cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [42/50] git commit: updated refs/heads/CLOUDSTACK-8581 to 1a2e80b
Date Fri, 10 Jul 2015 10:08:37 GMT
coverity 1116511 and 1116513: try-with-resource on old upgrade script three issues seen by
coverity as two. only one occurence of leakage

Signed-off-by: Daan Hoogland <daan@onecht.net>


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

Branch: refs/heads/CLOUDSTACK-8581
Commit: f8691b2c69c9b72e91d30a4008d2c121d8045bd5
Parents: 3bedeea
Author: Daan Hoogland <daan@onecht.net>
Authored: Tue Jul 7 13:28:05 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Thu Jul 9 21:30:24 2015 +0200

----------------------------------------------------------------------
 .../upgrade/dao/Upgrade218to22Premium.java      | 32 +++++++++-----------
 1 file changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8691b2c/engine/schema/src/com/cloud/upgrade/dao/Upgrade218to22Premium.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade218to22Premium.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade218to22Premium.java
index edf453c..10ae5b0 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade218to22Premium.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade218to22Premium.java
@@ -57,42 +57,40 @@ public class Upgrade218to22Premium extends Upgrade218to22 {
     }
 
     private void updateUserStats(Connection conn) {
-        try {
-
-            // update device_id information
-            PreparedStatement pstmt =
-                conn.prepareStatement("update cloud_usage.user_statistics uus set device_id
= " + "(select device_id from cloud.user_statistics us where uus.id = us.id)");
+        try ( // update device_id information
+            PreparedStatement pstmt = conn.prepareStatement(
+                    "update cloud_usage.user_statistics uus set device_id = (select device_id
from cloud.user_statistics us where uus.id = us.id)"
+                    );
+            ) {
             pstmt.executeUpdate();
-            pstmt.close();
 
             s_logger.debug("Upgraded cloud_usage user_statistics with deviceId");
+        } catch (Exception e) {
+            throw new CloudRuntimeException("Failed to upgrade user stats: ", e);
+        }
 
-            // update host_id information in usage_network
-            PreparedStatement pstmt1 =
-                conn.prepareStatement("update cloud_usage.usage_network un set host_id =
"
+        try ( // update host_id information in usage_network
+            PreparedStatement pstmt1 = conn.prepareStatement(
+                    "update cloud_usage.usage_network un set host_id = "
                     + "(select device_id from cloud_usage.user_statistics us where us.account_id
= un.account_id and us.data_center_id = un.zone_id)");
+                ) {
             pstmt1.executeUpdate();
-            pstmt1.close();
 
             s_logger.debug("Upgraded cloud_usage usage_network with hostId");
-
         } catch (Exception e) {
-            throw new CloudRuntimeException("Failed to upgrade user stats: ", e);
+            throw new CloudRuntimeException("Failed to upgrade network usage stats: ", e);
         }
     }
 
     private void updateUsageIpAddress(Connection conn) {
-        try {
-
-            // update id information
+        try ( // update id information
             PreparedStatement pstmt =
                 conn.prepareStatement("update cloud_usage.usage_ip_address uip set id = "
                     + "(select id from cloud.user_ip_address ip where uip.public_ip_address
= ip.public_ip_address and ip.data_center_id = uip.zone_id)");
+            ) {
             pstmt.executeUpdate();
-            pstmt.close();
 
             s_logger.debug("Upgraded cloud_usage usage_ip_address with Id");
-
         } catch (Exception e) {
             throw new CloudRuntimeException("Failed to upgrade usage_ip_address: ", e);
         }


Mime
View raw message