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/06/20 03:37:38 UTC

git commit: updated refs/heads/master to 916a6d0

Repository: cloudstack
Updated Branches:
  refs/heads/master 9eff27a08 -> 916a6d010


findbugs: prepare prepared statements to leverage the advantages of'em

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

This closes #496


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

Branch: refs/heads/master
Commit: 916a6d0104b1e33eda495f987fa08f123c2207f6
Parents: 9eff27a
Author: Daan Hoogland <da...@onecht.net>
Authored: Sat Jun 20 00:16:19 2015 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Sat Jun 20 03:37:20 2015 +0200

----------------------------------------------------------------------
 .../com/cloud/configuration/ConfigurationManagerImpl.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/916a6d01/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 315fa8c..50e120a 100644
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -929,7 +929,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
 
             if(tableName.equals("vm_instance")) {
-                selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
+                selectSql += " AND state != ? AND removed IS NULL";
             }
 
             if (tableName.equals("host") || tableName.equals("cluster") || tableName.equals("volumes")) {
@@ -943,6 +943,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 stmt.setString(2,tableName);
                 stmt.setString(3,column);
                 stmt.setLong(4, podId);
+                if(tableName.equals("vm_instance")) {
+                    stmt.setString(5, VirtualMachine.State.Expunging.toString());
+                }
                 final ResultSet rs = stmt.executeQuery();
                 if (rs != null && rs.next()) {
                     throw new CloudRuntimeException("The pod cannot be deleted because " + errorMsg);
@@ -1407,7 +1410,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             }
 
             if (tableName.equals("vm_instance")) {
-                selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
+                selectSql += " AND state != ? AND removed IS NULL";
             }
 
             final TransactionLegacy txn = TransactionLegacy.currentTxn();
@@ -1417,6 +1420,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 stmt.setString(2,tableName);
                 stmt.setString(3,column);
                 stmt.setLong(4, zoneId);
+                if (tableName.equals("vm_instance")) {
+                    stmt.setString(5, VirtualMachine.State.Expunging.toString());
+                }
                 final ResultSet rs = stmt.executeQuery();
                 if (rs != null && rs.next()) {
                     throw new CloudRuntimeException("The zone is not deletable because " + errorMsg);