aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorr.bogacki <r.bogacki@samsung.com>2019-02-11 09:08:38 +0100
committerRobert Bogacki <r.bogacki@samsung.com>2019-02-11 08:12:55 +0000
commit9929ba3bc7364d3376314abe87c2ca23a79f5c7a (patch)
treebcd32eff288df5f50e9b804c5066a5c070de1f47 /src/main/java/org
parentdd899213724ceaab3bb141dfb5cbf4eb7b89404a (diff)
Sonar vulnerability fixes in CronJobManager
Change-Id: I16133a60013cc63dd389a1aa14ddda693441570b Issue-ID: MUSIC-320 Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Diffstat (limited to 'src/main/java/org')
-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);
}
}
}