aboutsummaryrefslogtreecommitdiffstats
path: root/music-core
diff options
context:
space:
mode:
authorBrendan Tschaen <ctschaen@att.com>2020-05-18 17:59:03 +0000
committerGerrit Code Review <gerrit@onap.org>2020-05-18 17:59:03 +0000
commit425ef488b7d634e78d88bdeb2503104b59012d13 (patch)
tree72b3589bce126073bdb93b1be31b551601f75168 /music-core
parente826554678ac9214dc23724c2988dfb9a61af3ea (diff)
parentf7ea098b42425bfa381cb6be9adf957c0ea9b62a (diff)
Merge "Sonar issue fix in LockCleanUpDaemon"
Diffstat (limited to 'music-core')
-rw-r--r--music-core/src/main/java/org/onap/music/lockingservice/cassandra/LockCleanUpDaemon.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/music-core/src/main/java/org/onap/music/lockingservice/cassandra/LockCleanUpDaemon.java b/music-core/src/main/java/org/onap/music/lockingservice/cassandra/LockCleanUpDaemon.java
index 492a48f0..623a07c7 100644
--- a/music-core/src/main/java/org/onap/music/lockingservice/cassandra/LockCleanUpDaemon.java
+++ b/music-core/src/main/java/org/onap/music/lockingservice/cassandra/LockCleanUpDaemon.java
@@ -23,12 +23,10 @@
package org.onap.music.lockingservice.cassandra;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.onap.music.datastore.MusicDataStoreHandle;
import org.onap.music.datastore.PreparedQueryObject;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
-import org.onap.music.exceptions.MusicQueryException;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
@@ -58,7 +56,8 @@ public class LockCleanUpDaemon extends Thread {
try {
Thread.sleep(MusicUtil.getLockDaemonSleepTimeMs());
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.warn(EELFLoggerDelegate.applicationLogger, "Interrupted exception", e);
+
}
}
}
@@ -110,12 +109,14 @@ public class LockCleanUpDaemon extends Thread {
private void deleteLockIfStale(String lockTable, Row lock) throws MusicServiceException {
- if (lock.isNull("createtime") && lock.isNull("acquiretime")) {
+ final String CREATETIME="createtime";
+ final String ACQUIRETIME="acquiretime";
+ if (lock.isNull(CREATETIME) && lock.isNull("acquiretime")) {
return;
}
- long createTime = lock.isNull("createtime") ? 0 : Long.parseLong(lock.getString("createtime"));
- long acquireTime = lock.isNull("acquiretime") ? 0 : Long.parseLong(lock.getString("acquiretime"));
+ long createTime = lock.isNull(CREATETIME) ? 0 : Long.parseLong(lock.getString(CREATETIME));
+ long acquireTime = lock.isNull(ACQUIRETIME) ? 0 : Long.parseLong(lock.getString(ACQUIRETIME));
long row_access_time = Math.max(createTime, acquireTime);
if (System.currentTimeMillis() > row_access_time + MusicUtil.getDefaultLockLeasePeriod()) {
logger.info(EELFLoggerDelegate.applicationLogger, "Stale lock detected and being removed: " + lock);