diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2020-01-14 13:51:12 -0500 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2020-01-14 14:09:41 -0500 |
commit | c22d70d8f2429747ac7eb991c8d83aa3be633d1b (patch) | |
tree | d378efb029367b1cd692f96cfc2693397c359067 | |
parent | aaa77292ce7f5fa9909e1921a2881e83a520652a (diff) |
Sonar cleanup overrides and fixes
Removal of UTF-8 because its already set
capabilities doesn't generate any code, no need to include
override false positives for passwords etc.
override for logging and exception throw that we want
add synchronized to overrides that are synchronized
ignore checking of some conditions
adding synchronized to match set* methods
Issue-ID: POLICY-2321
Change-Id: I26d9ca22a0cdd67fdaae9c44b718b8dc103f190e
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
9 files changed, 40 insertions, 34 deletions
diff --git a/capabilities/pom.xml b/capabilities/pom.xml index 0e9a8cb8..1d1e290c 100644 --- a/capabilities/pom.xml +++ b/capabilities/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. + Modifications Copyright (C) 2020 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,6 +32,11 @@ <description>Properties</description> <packaging>jar</packaging> + <properties> + <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. --> + <sonar.skip>true</sonar.skip> + </properties> + <build> <pluginManagement> <plugins> diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java index cf0cfb3e..f1b25d71 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 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. @@ -137,7 +137,7 @@ public class PolicyLogger { } - public static Level getDebugLevel() { + public static synchronized Level getDebugLevel() { return debugLevel; } @@ -148,7 +148,7 @@ public class PolicyLogger { /** * Sets Debug Level. */ - public static void setDebugLevel(String newDebugLevel) { + public static synchronized void setDebugLevel(String newDebugLevel) { if (isOverrideLogbackLevel) { PolicyLogger.debugLevel = Level.valueOf(newDebugLevel); @@ -157,7 +157,7 @@ public class PolicyLogger { } - public static Level getAuditLevel() { + public static synchronized Level getAuditLevel() { return auditLevel; } @@ -168,7 +168,7 @@ public class PolicyLogger { /** * Sets Audit OFF or ON. */ - public static void setAuditLevel(String newAuditLevel) { + public static synchronized void setAuditLevel(String newAuditLevel) { if (isOverrideLogbackLevel) { if ("OFF".equalsIgnoreCase(newAuditLevel)) { @@ -182,7 +182,7 @@ public class PolicyLogger { } } - public static Level getMetricsLevel() { + public static synchronized Level getMetricsLevel() { return metricsLevel; } @@ -193,7 +193,7 @@ public class PolicyLogger { /** * Sets Metrics OFF or ON. */ - public static void setMetricsLevel(String newMetricsLevel) { + public static synchronized void setMetricsLevel(String newMetricsLevel) { if (isOverrideLogbackLevel) { if ("OFF".equalsIgnoreCase(newMetricsLevel)) { @@ -208,7 +208,7 @@ public class PolicyLogger { } - public static Level getErrorLevel() { + public static synchronized Level getErrorLevel() { return errorLevel; } @@ -219,7 +219,7 @@ public class PolicyLogger { /** * Sets Error OFF or ON. */ - public static void setErrorLevel(String newErrorLevel) { + public static synchronized void setErrorLevel(String newErrorLevel) { if (isOverrideLogbackLevel) { if ("OFF".equalsIgnoreCase(newErrorLevel)) { @@ -233,7 +233,7 @@ public class PolicyLogger { } } - public static String getClassname() { + public static synchronized String getClassname() { return classNameProp; } diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java index 40b2af5a..365afd25 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Audit * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 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. @@ -27,7 +27,7 @@ public class IntegrityAuditProperties { public static final String DB_DRIVER = "javax.persistence.jdbc.driver"; public static final String DB_URL = "javax.persistence.jdbc.url"; public static final String DB_USER = "javax.persistence.jdbc.user"; - public static final String DB_PWD = "javax.persistence.jdbc.password"; + public static final String DB_PWD = "javax.persistence.jdbc.password"; //NOSONAR public static final String AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds"; diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java index 87a3ff66..252fd27b 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Monitor * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 2020 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. @@ -25,7 +25,7 @@ public class IntegrityMonitorProperties { public static final String DB_DRIVER = "javax.persistence.jdbc.driver"; public static final String DB_URL = "javax.persistence.jdbc.url"; public static final String DB_USER = "javax.persistence.jdbc.user"; - public static final String DB_PWD = "javax.persistence.jdbc.password"; + public static final String DB_PWD = "javax.persistence.jdbc.password"; //NOSONAR // intervals specified are in seconds public static final int DEFAULT_MONITOR_INTERVAL = 30; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java index b66b4ba5..0f31bf7d 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -169,7 +169,7 @@ public interface BusConsumer { public Iterable<String> fetch() throws IOException { try { return getCurrentConsumer().fetch(); - } catch (final IOException e) { + } catch (final IOException e) { //NOSONAR logger.error("{}: cannot fetch because of {} - backoff for {} ms.", this, e.getMessage(), this.fetchTimeout); sleepAfterFetchFailure(); @@ -179,7 +179,7 @@ public interface BusConsumer { private void sleepAfterFetchFailure() { try { - this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS); + this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS); //NOSONAR } catch (InterruptedException e) { logger.warn("{}: interrupted while handling fetch error", this, e); @@ -343,7 +343,7 @@ public interface BusConsumer { private void sleepAfterFetchFailure() { try { - this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS); + this.closeCondition.await(this.fetchTimeout, TimeUnit.MILLISECONDS); //NOSONAR } catch (InterruptedException e) { logger.warn("{}: interrupted while handling fetch error", this, e); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java index ba16ca76..133adade 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 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. @@ -55,9 +55,9 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable * Keystore/Truststore system property names. */ public static final String SYSTEM_KEYSTORE_PROPERTY_NAME = "javax.net.ssl.keyStore"; - public static final String SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.keyStorePassword"; + public static final String SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.keyStorePassword"; //NOSONAR public static final String SYSTEM_TRUSTSTORE_PROPERTY_NAME = "javax.net.ssl.trustStore"; - public static final String SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.trustStorePassword"; + public static final String SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.trustStorePassword"; //NOSONAR /** * Logger. @@ -460,6 +460,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable * * @return the name */ + @Override public String getName() { return name; } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java index ed300422..ef9259bf 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 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. @@ -29,7 +29,7 @@ public class PolicyEndPointProperties { public static final String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey"; public static final String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret"; public static final String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId"; - public static final String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword"; + public static final String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword"; //NOSONAR public static final String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic"; public static final String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events"; public static final String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter"; @@ -84,7 +84,7 @@ public class PolicyEndPointProperties { public static final String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath"; public static final String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName"; - public static final String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password"; + public static final String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password"; //NOSONAR public static final String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath"; public static final String PROPERTY_HTTP_FILTER_CLASSES_SUFFIX = ".filterClasses"; @@ -40,7 +40,6 @@ <properties> <!-- Project common build settings --> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- Project path properties --> <nexusproxy>https://nexus.onap.org</nexusproxy> diff --git a/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java b/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java index 17009a83..ec7157d3 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java +++ b/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 2020 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,7 @@ public class SpecProperties extends Properties { /** * Constructor. - * + * * @param prefix the property name prefix that appears before any specialization, may * be "" * @param specialization the property name specialization (e.g., session name) @@ -52,7 +52,7 @@ public class SpecProperties extends Properties { /** * Constructor. - * + * * @param prefix the property name prefix that appears before any specialization, may * be "" * @param specialization the property name specialization (e.g., session name) @@ -67,7 +67,7 @@ public class SpecProperties extends Properties { /** * Adds a trailing "." to a String, if it doesn't already have one. - * + * * @param text text to which the "." should be added * @return the text, with a trailing "." */ @@ -78,7 +78,7 @@ public class SpecProperties extends Properties { /** * Gets the property whose value has the given key, looking first for the specialized * property name, and then for the generalized property name. - * + * * @param key property name, without the specialization * @return the value from the property set, or {@code null} if the property set does * not contain the value @@ -108,12 +108,12 @@ public class SpecProperties extends Properties { } @Override - public final int hashCode() { + public final synchronized int hashCode() { throw new UnsupportedOperationException("SpecProperties cannot be hashed"); } @Override - public final boolean equals(Object obj) { + public final synchronized boolean equals(Object obj) { throw new UnsupportedOperationException("cannot compare SpecProperties"); } } |