You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/06/18 12:37:52 UTC
git commit: updated refs/heads/master to 931cb95
Repository: cloudstack
Updated Branches:
refs/heads/master b678b4779 -> 931cb9502
Fix 2 findbugs SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING warnings in ConfigurationManagerImpl.java
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
This closes #476
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/931cb950
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/931cb950
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/931cb950
Branch: refs/heads/master
Commit: 931cb9502252ef89f8c4962bc1b9201cfda601a5
Parents: b678b47
Author: Rafael da Fonseca <rs...@gmail.com>
Authored: Wed Jun 17 20:59:43 2015 +0200
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Thu Jun 18 13:37:39 2015 +0300
----------------------------------------------------------------------
.../cloud/configuration/ConfigurationManagerImpl.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/931cb950/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 445ffde..315fa8c 100644
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -926,7 +926,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
dbName = "cloud";
}
- String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
+ String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
if(tableName.equals("vm_instance")) {
selectSql += " AND state != '" + VirtualMachine.State.Expunging.toString() + "' AND removed IS NULL";
@@ -939,7 +939,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
final TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
final PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
- stmt.setLong(1, podId);
+ stmt.setString(1,dbName);
+ stmt.setString(2,tableName);
+ stmt.setString(3,column);
+ stmt.setLong(4, podId);
final ResultSet rs = stmt.executeQuery();
if (rs != null && rs.next()) {
throw new CloudRuntimeException("The pod cannot be deleted because " + errorMsg);
@@ -1385,7 +1388,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
final String dbName = "cloud";
- String selectSql = "SELECT * FROM `" + dbName + "`.`" + tableName + "` WHERE " + column + " = ?";
+ String selectSql = "SELECT * FROM `?`.`?` WHERE ? = ?";
if (tableName.equals("op_dc_vnet_alloc")) {
selectSql += " AND taken IS NOT NULL";
@@ -1410,7 +1413,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
final TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
final PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
- stmt.setLong(1, zoneId);
+ stmt.setString(1,dbName);
+ stmt.setString(2,tableName);
+ stmt.setString(3,column);
+ stmt.setLong(4, zoneId);
final ResultSet rs = stmt.executeQuery();
if (rs != null && rs.next()) {
throw new CloudRuntimeException("The zone is not deletable because " + errorMsg);