From 72504e5853929bd0d649fc3bc42d3e91fc60c079 Mon Sep 17 00:00:00 2001 From: ezhil Date: Wed, 5 Dec 2018 20:33:08 +0530 Subject: Fixed sonar issues in PollingWorker.java Fixed logger issues Issue-ID: CCSDK-791 Change-Id: Ie1759c8778ff896b2cff3e187308e6a10265e966 Signed-off-by: ezhil --- .../ccsdk/sli/core/dblib/pm/PollingWorker.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java index 4bfa058a..b44e2f89 100644 --- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java +++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java @@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicLong; public class PollingWorker implements Runnable { - private Logger LOGGER = LoggerFactory.getLogger(PollingWorker.class); + private Logger logger = LoggerFactory.getLogger(PollingWorker.class); private static PollingWorker self = null; @@ -47,17 +47,6 @@ public class PollingWorker implements Runnable { private static boolean enabled = false; private Timer timer = null; - public static void post(long starttime){ - PollingWorker temp = self; - if(temp != null && enabled) { - temp.register(new TestSample(starttime)); - } - } - - public static void createInistance(Properties props){ - self = new PollingWorker(props); - } - private PollingWorker(Properties ctxprops){ if(ctxprops==null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm") == null){ enabled = false; @@ -89,6 +78,18 @@ public class PollingWorker implements Runnable { timer.schedule(new MyTimerTask(), interval*1000L, interval*1000L); } } + public static void post(long starttime){ + PollingWorker temp = self; + if(temp != null && enabled) { + temp.register(new TestSample(starttime)); + } + } + + public static void createInistance(Properties props){ + self = new PollingWorker(props); + } + + private void register(TestSample object){ try { @@ -113,12 +114,14 @@ public class PollingWorker implements Runnable { consume((TestSample)next); } else { System.out.println(next.getClass().getName()); + logger.error(next.getClass().getName()); } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); + } } @@ -146,7 +149,7 @@ public class PollingWorker implements Runnable { } sb.append(tmp2[i].get()).append("\t"); } - LOGGER.info(sb.toString()); + logger.info(sb.toString()); } class MyTimerTask extends TimerTask{ -- cgit 1.2.3-korg