aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBharath Balasubramanian <bharathb@research.att.com>2019-02-13 13:46:18 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-13 13:46:18 +0000
commit3e8eaf4d075ea7ca92ad9b51ed51d402269ee27a (patch)
tree6a34da8b66d5645a844eb518accee4d40cdba956
parentb9b6fb0db83390c80eec5a38a051a4cf2e881293 (diff)
parent9929ba3bc7364d3376314abe87c2ca23a79f5c7a (diff)
Merge "Sonar vulnerability fixes in CronJobManager"
-rw-r--r--src/main/java/org/onap/music/main/CronJobManager.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/main/java/org/onap/music/main/CronJobManager.java b/src/main/java/org/onap/music/main/CronJobManager.java
index 9cd9f33f..ea2fa685 100644
--- a/src/main/java/org/onap/music/main/CronJobManager.java
+++ b/src/main/java/org/onap/music/main/CronJobManager.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -25,12 +27,6 @@ package org.onap.music.main;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.annotation.WebListener;
import org.onap.music.datastore.PreparedQueryObject;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
@@ -52,13 +48,13 @@ public class CronJobManager {
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
-
+
@Scheduled(cron = "0 0 0 * * ?")
public void scheduleTaskWithFixedRate() {
logger.info("Executing cronjob to cleanup locks..", dateTimeFormatter.format(LocalDateTime.now()) );
deleteLocksFromDB();
}
-
+
public void deleteLocksFromDB() {
PreparedQueryObject pQuery = new PreparedQueryObject();
String consistency = MusicUtil.EVENTUAL;
@@ -69,10 +65,9 @@ public class CronJobManager {
logger.error(EELFLoggerDelegate.errorLogger,"Error creating Admin.locks table.",AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
}
} catch (MusicServiceException e1) {
- logger.error(EELFLoggerDelegate.errorLogger,e1.getMessage(),AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
- e1.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger,e1,AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
}
-
+
pQuery = new PreparedQueryObject();
pQuery.appendQueryString(
"select * from admin.locks");
@@ -82,7 +77,7 @@ public class CronJobManager {
StringBuilder deleteKeys = new StringBuilder();
Boolean expiredKeys = false;
while (it.hasNext()) {
- Row row = (Row) it.next();
+ Row row = it.next();
String id = row.getString("lock_id");
long ctime = Long.parseLong(row.getString("ctime"));
if(System.currentTimeMillis() >= ctime + 24 * 60 * 60 * 1000) {
@@ -102,8 +97,7 @@ public class CronJobManager {
CachingUtil.deleteKeysFromDB(deleteKeys.toString());
}
} catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(),AppMessages.CACHEERROR,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger,e,AppMessages.CACHEERROR,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
}
}
}