cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [02/10] git commit: updated refs/heads/master to b0136c5
Date Thu, 09 Jul 2015 19:30:45 GMT
coverity 1116507: one off old upgrade code trivial fix however

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/79709cd4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/79709cd4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/79709cd4

Branch: refs/heads/master
Commit: 79709cd490e559e8042c6909c1d60d21fe42d598
Parents: dae2e05
Author: Daan Hoogland <daan@onecht.net>
Authored: Tue Jul 7 12:52:37 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Thu Jul 9 21:30:23 2015 +0200

----------------------------------------------------------------------
 .../upgrade/dao/Upgrade222to224Premium.java     | 24 ++++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79709cd4/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224Premium.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224Premium.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224Premium.java
index 921c5e6..775c140 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224Premium.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade222to224Premium.java
@@ -60,25 +60,25 @@ public class Upgrade222to224Premium extends Upgrade222to224 {
     }
 
     private void updateUserStats(Connection conn) {
-        try {
+        try (   // update network_id information
+                PreparedStatement pstmt = conn.prepareStatement(
+                    "update cloud_usage.user_statistics uus, cloud.user_statistics us set
uus.network_id = us.network_id where uus.id = us.id"
+                    );
+            ) {
 
-            // update network_id information
-            PreparedStatement pstmt =
-                conn.prepareStatement("update cloud_usage.user_statistics uus, cloud.user_statistics
us set uus.network_id = " + "us.network_id where uus.id = us.id");
             pstmt.executeUpdate();
-            pstmt.close();
-
             s_logger.debug("Upgraded cloud_usage user_statistics with networkId");
+        } catch (Exception e) {
+            throw new CloudRuntimeException("Failed to upgrade user stats: ", e);
+        }
 
-            // update network_id information in usage_network
-            PreparedStatement pstmt1 =
-                conn.prepareStatement("update cloud_usage.usage_network un, cloud_usage.user_statistics
us set un.network_id = "
+        try (   // update network_id information in usage_network
+                PreparedStatement pstmt1 =
+                    conn.prepareStatement("update cloud_usage.usage_network un, cloud_usage.user_statistics
us set un.network_id = "
                     + "us.network_id where us.account_id = un.account_id and us.data_center_id
= un.zone_id and us.device_id = un.host_id");
+            ) {
             pstmt1.executeUpdate();
-            pstmt1.close();
-
             s_logger.debug("Upgraded cloud_usage usage_network with networkId");
-
         } catch (Exception e) {
             throw new CloudRuntimeException("Failed to upgrade user stats: ", e);
         }


Mime
View raw message