aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2018-08-29 11:47:06 +0900
committerParshad Patel <pars.patel@samsung.com>2018-09-10 10:59:47 +0900
commit886f66042472d9f1c4a7f9e848263d55750e8cfe (patch)
tree64c150e2a7c60b7a03e8131549938986fd1a654e /src/main/java/org
parent5addbb146376be59dfa09d7c9eb175056f0febdb (diff)
Fix critical sonar issues
Fix DateFormat static declaration & log exception issue Issue-ID: AAI-1368 Change-Id: Ie4c9677e5b8aad8a7220cf806ceb45a9484ccb07 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/aai/datacleanup/DataCleanupTasks.java3
-rw-r--r--src/main/java/org/onap/aai/datasnapshot/DataSnapshotTasks.java17
2 files changed, 7 insertions, 13 deletions
diff --git a/src/main/java/org/onap/aai/datacleanup/DataCleanupTasks.java b/src/main/java/org/onap/aai/datacleanup/DataCleanupTasks.java
index 1931491..a281d70 100644
--- a/src/main/java/org/onap/aai/datacleanup/DataCleanupTasks.java
+++ b/src/main/java/org/onap/aai/datacleanup/DataCleanupTasks.java
@@ -47,8 +47,7 @@ import com.att.eelf.configuration.EELFManager;
public class DataCleanupTasks {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(DataCleanupTasks.class);
- private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
-
+ private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
/**The function archives/deletes files that end in .out (Ie. dataGrooming.201511111305.out) that sit in our log/data directory structure.
logDir is the {project_home}/logs
archiveDir is the ARCHIVE directory where the files will be stored after 5 days.
diff --git a/src/main/java/org/onap/aai/datasnapshot/DataSnapshotTasks.java b/src/main/java/org/onap/aai/datasnapshot/DataSnapshotTasks.java
index cc9ca97..404e243 100644
--- a/src/main/java/org/onap/aai/datasnapshot/DataSnapshotTasks.java
+++ b/src/main/java/org/onap/aai/datasnapshot/DataSnapshotTasks.java
@@ -29,6 +29,7 @@ import org.onap.aai.datagrooming.DataGrooming;
import org.onap.aai.datagrooming.DataGroomingTasks;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.util.AAIConfig;
import org.springframework.context.annotation.PropertySource;
@@ -42,7 +43,7 @@ import com.att.eelf.configuration.EELFManager;
public class DataSnapshotTasks {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DataSnapshotTasks.class);
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+ private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Scheduled(cron = "${datasnapshottasks.cron}" )
public void snapshotScheduleTask() throws AAIException, Exception {
@@ -66,10 +67,9 @@ public class DataSnapshotTasks {
LOGGER.info("Started cron job dataSnapshot @ " + dateFormat.format(new Date()));
try {
if (AAIConfig.get("aai.cron.enable.dataSnapshot").equals("true")) {
- DataSnapshot dataSnapshot = new DataSnapshot();
String [] dataSnapshotParms = AAIConfig.get("aai.datasnapshot.params", "JUST_TAKE_SNAPSHOT").split("\\s+");
LOGGER.info("DataSnapshot Params {}", Arrays.toString(dataSnapshotParms));
- dataSnapshot.main(dataSnapshotParms);
+ DataSnapshot.main(dataSnapshotParms);
}
}
catch (Exception e) {
@@ -93,7 +93,6 @@ public class DataSnapshotTasks {
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
-
while (br.readLine() != null){
count++;
}
@@ -101,15 +100,11 @@ public class DataSnapshotTasks {
int exitVal = process.waitFor();
LOGGER.info("Exit value of the dataSnapshot check process: " + exitVal);
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception in checkIfDataSnapshotIsRunning" + LogFormatTools.getStackTop(e));
}
- if(count > 0){
- return true;
- } else {
- return false;
- }
+ return count > 0;
}
}
- \ No newline at end of file
+