cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [2/3] git commit: updated refs/heads/master to 03b076c
Date Fri, 17 Jul 2015 11:22:58 GMT
coverity 1116696: iprange adding code cleaned

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

Branch: refs/heads/master
Commit: e92e800930c66ed14a3f3623ac394e4d7410da58
Parents: f15eaec
Author: Daan Hoogland <daan@onecht.net>
Authored: Thu Jul 16 16:21:00 2015 +0200
Committer: Daan Hoogland <daan@onecht.net>
Committed: Fri Jul 17 13:22:42 2015 +0200

----------------------------------------------------------------------
 .../dc/dao/DataCenterIpAddressDaoImpl.java      | 23 ++++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e92e8009/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
index 9bc373f..ca79eed 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterIpAddressDaoImpl.java
@@ -116,7 +116,6 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
         String insertSql = "INSERT INTO `cloud`.`op_dc_ip_address_alloc` (ip_address, data_center_id,
pod_id, mac_address) " +
             "VALUES (?, ?, ?, (select mac_address from `cloud`.`data_center` where id=?))";
         String updateSql = "UPDATE `cloud`.`data_center` set mac_address = mac_address+1
where id=?";
-        PreparedStatement stmt = null;
 
         long startIP = NetUtils.ip2Long(start);
         long endIP = NetUtils.ip2Long(end);
@@ -125,17 +124,17 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre
             txn.start();
 
             while (startIP <= endIP) {
-                stmt = txn.prepareStatement(insertSql);
-                stmt.setString(1, NetUtils.long2Ip(startIP++));
-                stmt.setLong(2, dcId);
-                stmt.setLong(3, podId);
-                stmt.setLong(4, dcId);
-                stmt.executeUpdate();
-                stmt.close();
-                stmt = txn.prepareStatement(updateSql);
-                stmt.setLong(1, dcId);
-                stmt.executeUpdate();
-                stmt.close();
+                try(PreparedStatement insertPstmt = txn.prepareStatement(insertSql);) {
+                    insertPstmt.setString(1, NetUtils.long2Ip(startIP++));
+                    insertPstmt.setLong(2, dcId);
+                    insertPstmt.setLong(3, podId);
+                    insertPstmt.setLong(4, dcId);
+                    insertPstmt.executeUpdate();
+                }
+                try(PreparedStatement updatePstmt = txn.prepareStatement(updateSql);) {
+                    updatePstmt.setLong(1, dcId);
+                    updatePstmt.executeUpdate();
+                }
             }
             txn.commit();
         } catch (SQLException ex) {


Mime
View raw message