From d9dc69b70251551160466fd76a51a8ff16b4bdd0 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Mon, 12 Nov 2018 21:02:13 +0900 Subject: Fix sonar critical issue in common-app-api Fix use "isAssignableFrom" instead issue Issue-ID: SDC-1895 Change-Id: Ifb51c4bca8df5dd7cdb95bbf5baa1b39004dd1ea Signed-off-by: Parshad Patel --- .../openecomp/sdc/common/log/elements/LoggerFactory.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java index de02c067c8..d294f41e98 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java @@ -15,19 +15,19 @@ public class LoggerFactory { @SuppressWarnings("unchecked") public static V getLogger(Class type, Logger logger) { - if (type.getName().equals(LoggerAudit.class.getName())) { + if (type.isAssignableFrom(LoggerAudit.class)) { return (V) new LoggerAudit(new LogFieldsMdcHandler(), logger); } - if (type.getName().equals(LoggerDebug.class.getName())) { + if (type.isAssignableFrom(LoggerDebug.class)) { return (V) new LoggerDebug(new LogFieldsMdcHandler(), logger); } - if (type.getName().equals(LoggerMetric.class.getName())) { + if (type.isAssignableFrom(LoggerMetric.class)) { return (V) new LoggerMetric(new LogFieldsMdcHandler(), logger); } - if (type.getName().equals(LoggerError.class.getName())) { + if (type.isAssignableFrom(LoggerError.class)) { return (V) new LoggerError(new LogFieldsMdcHandler(), logger); } @@ -37,19 +37,19 @@ public class LoggerFactory { @SuppressWarnings("unchecked") public static V getMdcLogger(Class type, Logger logger) { - if (type.getName().equals(LoggerAudit.class.getName())) { + if (type.isAssignableFrom(LoggerAudit.class)) { return (V) new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger); } - if (type.getName().equals(LoggerDebug.class.getName())) { + if (type.isAssignableFrom(LoggerDebug.class)) { return (V) new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger); } - if (type.getName().equals(LoggerMetric.class.getName())) { + if (type.isAssignableFrom(LoggerMetric.class)) { return (V) new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger); } - if (type.getName().equals(LoggerError.class.getName())) { + if (type.isAssignableFrom(LoggerError.class)) { return (V) new LoggerError(LogFieldsMdcHandler.getInstance(), logger); } -- cgit 1.2.3-korg