diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2021-05-07 18:09:13 -0500 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2021-05-07 18:09:13 -0500 |
commit | 16a9a1018dd6e9390543a27970174d8fd00a68bd (patch) | |
tree | 0c779c0674aef86ff6ceb1a1e7d9dade5783c115 /policy-utils | |
parent | c2e25b77402244fdc9f443628ec127e03606c9f6 (diff) |
sonars policy-utils and feature-lifecycle
Issue-ID: POLICY-3289
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: Iaf7423f840fb39a27c3e5fd293159d1336d5557a
Diffstat (limited to 'policy-utils')
3 files changed, 14 insertions, 23 deletions
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/policies/DomainMaker.java b/policy-utils/src/main/java/org/onap/policy/drools/policies/DomainMaker.java index 37966653..6266f171 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/policies/DomainMaker.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/policies/DomainMaker.java @@ -162,7 +162,7 @@ public class DomainMaker { // A known schema is one that embedded in a .jar in the classpath as a resource // matching the following syntax: <policy-type-name>-<policy-type-version>.schema.json. // - String schema = + var schema = ResourceUtils .getResourceAsString("schemas/" + policyType.getName() + "-" + policyType.getVersion() + ".schema.json"); diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java index 4d287170..10871e72 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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. @@ -31,7 +31,6 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.atomic.AtomicReference; -import org.apache.commons.configuration2.Configuration; import org.apache.commons.configuration2.ConfigurationConverter; import org.apache.commons.configuration2.SystemConfiguration; import org.onap.policy.common.utils.security.CryptoCoder; @@ -50,8 +49,7 @@ public class PropertyUtil { private static Timer timer = null; // this table maps canonical file into a 'ListenerRegistration' instance - private static HashMap<File, ListenerRegistration> registrations = - new HashMap<>(); + private static final HashMap<File, ListenerRegistration> registrations = new HashMap<>(); private static final Logger logger = LoggerFactory.getLogger(PropertyUtil.class.getName()); @@ -137,7 +135,7 @@ public class PropertyUtil { * a problem loading the properties file. */ public static Properties getProperties(File file, Listener listener) throws IOException { - File propFile = file; + var propFile = file; if (listener == null) { // no listener specified -- just fetch the properties return getProperties(propFile); @@ -198,7 +196,7 @@ public class PropertyUtil { * @return Properties - interpolated properties object */ public static Properties getInterpolatedProperties(Properties properties, CryptoCoder cryptoCoder) { - Configuration config = ConfigurationConverter.getConfiguration(properties); + var config = ConfigurationConverter.getConfiguration(properties); config.getInterpolator() .registerLookup(ENV_WITH_DEFAULT_PROPERTY_PREFIX, new EnvironmentVariableWithDefaultLookup()); @@ -207,7 +205,7 @@ public class PropertyUtil { } config.getInterpolator().registerLookup(CRYPTO_CODER_PROPERTY_PREFIX, new CryptoCoderValueLookup(cryptoCoder)); - Properties props = ConfigurationConverter.getProperties(config); + var props = ConfigurationConverter.getProperties(config); props.stringPropertyNames().forEach(key -> props.setProperty(key, cryptoCoder.decrypt(props.getProperty(key)))); return props; } @@ -223,8 +221,8 @@ public class PropertyUtil { */ protected static Properties getPropertiesFile(File file) throws IOException { // create an InputStream (may throw a FileNotFoundException) - Properties rval = new Properties(); - try (FileInputStream fis = new FileInputStream(file)) { + var rval = new Properties(); + try (var fis = new FileInputStream(file)) { // create the properties instance // load properties (may throw an IOException) @@ -381,7 +379,7 @@ public class PropertyUtil { lastModified = timestamp; // Save old set, and initial set of changed properties. - Properties oldProperties = properties; + var oldProperties = properties; HashSet<String> changedProperties = new HashSet<>(oldProperties.stringPropertyNames()); @@ -418,19 +416,12 @@ public class PropertyUtil { for (final Listener notify : listeners) { // Copy 'properties' and 'changedProperties', so it doesn't // cause problems if the recipient makes changes. - final Properties tmpProperties = - (Properties) properties.clone(); - final HashSet<String> tmpChangedProperties = - new HashSet<>(changedProperties); + final var tmpProperties = (Properties) properties.clone(); + final HashSet<String> tmpChangedProperties = new HashSet<>(changedProperties); // Do the notification in a separate thread, so blocking // won't cause any problems. - new Thread() { - @Override - public void run() { - notify.propertiesChanged(tmpProperties, tmpChangedProperties); - } - }.start(); + new Thread(() -> notify.propertiesChanged(tmpProperties, tmpChangedProperties)).start(); } } } diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java index 1697f697..60867528 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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. @@ -81,7 +81,7 @@ public class LoggerUtil { } final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - final ch.qos.logback.classic.Logger logger = context.getLogger(loggerName); + final var logger = context.getLogger(loggerName); if (logger == null) { throw new IllegalArgumentException("no logger " + loggerName); } |