From e3035927b9c49478e28e5ca7fca7c42c43b7300e Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 10 Feb 2021 14:23:02 -0500 Subject: More sonar issues in common Addressed the issues: - use of eq() in verify() - remove @NamedQueries - use computeIfAbsent() Issue-ID: POLICY-2914 Change-Id: I265bc98f0f326e7b4ce86c25e68fc4859bd7fb02 Signed-off-by: Jim Hahn --- .../java/org/onap/policy/common/logging/eelf/EventTrackInfo.java | 6 ++---- .../org/onap/policy/common/logging/flexlogger/FlexLogger.java | 9 ++------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'common-logging') diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java index 71476c6a..3e021169 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,9 +66,7 @@ public class EventTrackInfo { return; } // in case override the start time, check the original event was already stored or not - if (!eventInfo.containsKey(id)) { - eventInfo.put(id, event); - } + eventInfo.putIfAbsent(id, event); } } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java index eb6daee9..fadb2545 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -179,12 +179,7 @@ public class FlexLogger extends SecurityManager { String className = new FlexLogger().getClassName(); - if (!systemOutMap.containsKey(className)) { - SystemOutLogger logger = new SystemOutLogger(className); - systemOutMap.put(className, logger); - } - - return systemOutMap.get(className); + return systemOutMap.computeIfAbsent(className, SystemOutLogger::new); } /** -- cgit 1.2.3-korg