aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorMohammad Salehe <salehe@cs.toronto.edu>2019-02-08 11:19:35 -0500
committerMohammad Salehe <salehe@cs.toronto.edu>2019-02-24 22:23:38 -0500
commitfdc837a3e2b654cff60e8b9e1142840c07047338 (patch)
tree3ae3bf91413c1c182d365121ae04f2343ad67b8f /src/main/java
parentde0f2ca96ca7117c4587d5c73373da654404faf4 (diff)
Use query parameters instead of string concat
Change-Id: I477368dec2fe2ea994f02ed90822ee9dc6656945 Issue-ID: MUSIC-148 Signed-off-by: Mohammad Salehe <salehe@cs.toronto.edu>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java b/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
index 58163a8f..ec694ddc 100644
--- a/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
+++ b/src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java
@@ -269,21 +269,24 @@ public class CassaLockStore {
* @throws MusicServiceException
* @throws MusicQueryException
*/
- public void deQueueLockRef(String keyspace, String table, String key, String lockReference) throws MusicServiceException, MusicQueryException{
+ public void deQueueLockRef(String keyspace, String table, String key, String lockReference) throws MusicServiceException, MusicQueryException {
TimeMeasureInstance.instance().enter("deQueueLockRef");
try {
table = table_prepend_name+table;
PreparedQueryObject queryObject = new PreparedQueryObject();
Long lockReferenceL = Long.parseLong(lockReference);
- String deleteQuery = "delete from "+keyspace+"."+table+" where key='"+key+"' AND lockReference ="+lockReferenceL+" IF EXISTS;";
+ String deleteQuery = "delete from "+keyspace+"."+table+" where key=? AND lockReference =? IF EXISTS;";
queryObject.appendQueryString(deleteQuery);
- dsHandle.executePut(queryObject, "critical");
+ queryObject.addValue(key);
+ queryObject.addValue(lockReferenceL);
+ boolean pResult = dsHandle.executePut(queryObject, "critical");
+ if (pResult == false)
+ throw new MusicServiceException("Could not destroy lock " + key + " " + lockReferenceL);
}
finally {
TimeMeasureInstance.instance().exit();
}
}
-
public void updateLockAcquireTime(String keyspace, String table, String key, String lockReference) throws MusicServiceException, MusicQueryException{
TimeMeasureInstance.instance().enter("updateLockAcquireTime");