summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Koya <rk541m@att.com>2018-09-25 13:20:16 +0000
committerGerrit Code Review <gerrit@onap.org>2018-09-25 13:20:16 +0000
commitf29b6578ba3c5a8483d170c41e641e603c6d716b (patch)
treed545cd20b46ab8fac9d4b0111769f98c4b9fc196
parent02848499606b831885d8b77c2431dcb02d23cb0a (diff)
parent3186f028867610be7d1ae74b70bea8a70597bba0 (diff)
Merge "Fix PurgeLogDirTask vulnerabilities"
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java
index 7b0e0e61..14d15197 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/PurgeLogDirTask.java
@@ -27,24 +27,30 @@ package org.onap.dmaap.datarouter.provisioning.utils;
import java.io.File;
import java.util.Properties;
import java.util.TimerTask;
+import org.apache.log4j.Logger;
/**
- * This class provides a {@link TimerTask} that purges old logfiles
- * (older than the number of days specified by the org.onap.dmaap.datarouter.provserver.logretention property).
+ * This class provides a {@link TimerTask} that purges old logfiles (older than the number of days specified by the
+ * org.onap.dmaap.datarouter.provserver.logretention property).
*
* @author Robert Eby
* @version $Id: PurgeLogDirTask.java,v 1.2 2013/07/05 13:48:05 eby Exp $
*/
public class PurgeLogDirTask extends TimerTask {
+
private static final long ONEDAY = 86400000L;
private final String logdir;
private final long interval;
+ private Logger utilsLogger;
public PurgeLogDirTask() {
Properties p = (new DB()).getProperties();
logdir = p.getProperty("org.onap.dmaap.datarouter.provserver.accesslog.dir");
String s = p.getProperty("org.onap.dmaap.datarouter.provserver.logretention", "30");
+
+ this.utilsLogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.utils");
+
long n = 30;
try {
n = Long.parseLong(s);
@@ -61,12 +67,13 @@ public class PurgeLogDirTask extends TimerTask {
if (dir.exists()) {
long exptime = System.currentTimeMillis() - interval;
for (File logfile : dir.listFiles()) {
- if (logfile.lastModified() < exptime)
+ if (logfile.lastModified() < exptime) {
logfile.delete();
+ }
}
}
} catch (Exception e) {
- e.printStackTrace();
+ utilsLogger.error("Exception: " + e.getMessage());
}
}
}