Merge "More sonar issues in policy-common"
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
index 9bfbe68..369e77a 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java
@@ -67,7 +67,7 @@
* @param arguments output arguments
* @return
*/
- public static String formatMessage(String format, Object ...arguments) {
+ public static String formatMessage(String format, Object...arguments) {
if (arguments.length <= 0 || arguments[0] == null) {
return format;
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
index ab5712f..9116051 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
@@ -149,7 +149,7 @@
MESSAGE_ERROR_SAMPLE;
- /**
+ /*
* Static initializer to ensure the resource bundles for this class are loaded... Here this
* application loads messages from three bundles.
*/
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 c582ea8..870e63a 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
@@ -486,7 +486,7 @@
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
debugLogger.info(MessageCodes.GENERAL_INFO, message + arguments2);
return;
}
@@ -571,7 +571,7 @@
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
debugLogger.warn(MessageCodes.GENERAL_INFO, message + arguments2);
return;
}
@@ -661,7 +661,7 @@
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
errorLogger.error(MessageCodes.GENERAL_ERROR, message + arguments2);
return;
}
@@ -747,7 +747,7 @@
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
debugLogger.debug(MessageCodes.GENERAL_INFO, message + arguments2);
return;
}
@@ -1200,7 +1200,7 @@
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
metricsLogger.info(MessageCodes.RULE_METRICS_INFO, message + arguments2);
return;
}
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
index fd68045..1fe560d 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
@@ -111,8 +111,7 @@
if (ParameterGroup.class.isAssignableFrom(fieldType)) {
if (null != fieldObject) {
return ((ParameterGroup) fieldObject).validate();
- }
- else {
+ } else {
return new GroupValidationResult((ParameterGroup) fieldObject);
}
}
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
index 8f978c6..8795602 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
@@ -160,7 +160,7 @@
@Test
public void testValidateMap() {
- Map<String,ValidationResult> map = null;
+ Map<String, ValidationResult> map = null;
bean = new BeanValidationResult(NAME, OBJECT);
assertTrue(bean.validateMap(MY_MAP, map, validMapEntry()));
assertTrue(bean.isValid());
diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java
index 7276b50..bd2cf10 100644
--- a/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java
+++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/testclasses/TestParametersL10.java
@@ -109,8 +109,7 @@
public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) {
if (level == 0) {
return;
- }
- else {
+ } else {
level--;
}
diff --git a/gson/src/test/java/org/onap/policy/common/gson/DoubleConverterTest.java b/gson/src/test/java/org/onap/policy/common/gson/DoubleConverterTest.java
index c81a5cd..f4e3a76 100644
--- a/gson/src/test/java/org/onap/policy/common/gson/DoubleConverterTest.java
+++ b/gson/src/test/java/org/onap/policy/common/gson/DoubleConverterTest.java
@@ -59,7 +59,7 @@
assertEquals("[list, null, 21]", list.toString());
// map
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("map-A", "map-value");
map.put("map-B", null);
map.put("map-C", 22.0);
@@ -88,13 +88,13 @@
@Test
public void testConvertFromDoubleMap() {
// null is ok
- DoubleConverter.convertFromDouble((Map<String,Object>) null);
+ DoubleConverter.convertFromDouble((Map<String, Object>) null);
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("keyA", "valueA");
map.put("keyB", 200.0);
- Map<String,Object> nested = new LinkedHashMap<>();
+ Map<String, Object> nested = new LinkedHashMap<>();
map.put("keyC", nested);
nested.put("nested-key", 201.0);
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
index 28e8e38..ff4d297 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
@@ -332,7 +332,7 @@
*/
public IntegrityAuditEntity getMyIntegrityAuditEntity() throws DbDaoTransactionException {
- return updateIae("getMyIntegrityAuditEntity", this.resourceName, this.persistenceUnit, (em,iae) -> {
+ return updateIae("getMyIntegrityAuditEntity", this.resourceName, this.persistenceUnit, (em, iae) -> {
if (iae != null) {
// refresh the object from DB in case cached data was returned
@@ -404,7 +404,7 @@
*/
private void register(String altDbUrl) throws DbDaoTransactionException {
- updateIae("register", this.resourceName, this.persistenceUnit, (em,iae) -> {
+ updateIae("register", this.resourceName, this.persistenceUnit, (em, iae) -> {
IntegrityAuditEntity iae2 = iae;
// If it already exists, we just want to update the properties and lastUpdated date
@@ -460,7 +460,7 @@
logger.debug("setDesignated: enter, resourceName: " + resourceName + ", persistenceUnit: " + persistenceUnit
+ ", designated: " + desig);
- updateIae("setDesignated", resourceName, persistenceUnit, (em,iae) -> {
+ updateIae("setDesignated", resourceName, persistenceUnit, (em, iae) -> {
if (iae != null) {
// refresh the object from DB in case cached data was returned
@@ -493,7 +493,7 @@
* @throws DbDaoTransactionException if an error occurs
*/
private IntegrityAuditEntity updateIae(String methodName, String resourceName, String persistenceUnit,
- BiConsumer<EntityManager,IntegrityAuditEntity> updater) throws DbDaoTransactionException {
+ BiConsumer<EntityManager, IntegrityAuditEntity> updater) throws DbDaoTransactionException {
try {
EntityManager em = emf.createEntityManager();
@@ -547,7 +547,7 @@
logger.debug("setLastUpdated: enter, resourceName: " + this.resourceName + ", persistenceUnit: "
+ this.persistenceUnit);
- updateIae("setLastUpdated", this.resourceName, this.persistenceUnit, (em,iae) -> {
+ updateIae("setLastUpdated", this.resourceName, this.persistenceUnit, (em, iae) -> {
if (iae != null) {
// refresh the object from DB in case cached data was returned
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
index 33c51e2..6210392 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
@@ -359,7 +359,7 @@
// create instance of StateManagement class and pass emf to it
stateManager = new StateManagement(emf, resourceName);
- /**
+ /*
* Initialize the state and status attributes. This will maintain any Administrative state value but will
* set the operational state = enabled, availability status = null, standby status = null. The integrity
* monitor will set the operational state via the FPManager and the owning application must set the standby
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
index 65ebf2d..feca72f 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
@@ -147,7 +147,7 @@
* was updated, {@code null} if no change was made
* @throws StateManagementException if an error occurs
*/
- private void setState(String methodName, String resourceName, ExFunction<StateManagementEntity,String> updateState)
+ private void setState(String methodName, String resourceName, ExFunction<StateManagementEntity, String> updateState)
throws StateManagementException {
synchronized (SYNCLOCK) {
@@ -513,7 +513,7 @@
}
@FunctionalInterface
- private static interface ExFunction<T,R> {
+ private static interface ExFunction<T, R> {
public R update(T object) throws IntegrityMonitorException;
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
index 469794c..c2b590a 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
@@ -292,8 +292,8 @@
*/
public DmaapDmePublisherWrapper(BusTopicParams busTopicParams) {
- super(ProtocolTypeConstants.DME2, busTopicParams.getServers(),busTopicParams.getTopic(),
- busTopicParams.getUserName(),busTopicParams.getPassword(),busTopicParams.isUseHttps());
+ super(ProtocolTypeConstants.DME2, busTopicParams.getServers(), busTopicParams.getTopic(),
+ busTopicParams.getUserName(), busTopicParams.getPassword(), busTopicParams.isUseHttps());
String dme2RouteOffer = busTopicParams.isAdditionalPropsValid()
? busTopicParams.getAdditionalProps().get(
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
index 7e0d3ff..5cb220b 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/DmaapPropertyUtils.java
@@ -36,10 +36,10 @@
/**
* Maps a topic property to a DME property.
*/
- private static final Map<String,String> PROP_TO_DME;
+ private static final Map<String, String> PROP_TO_DME;
static {
- Map<String,String> map = new HashMap<>();
+ Map<String, String> map = new HashMap<>();
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX,
PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java
index 265346c..7f15502 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java
@@ -129,7 +129,7 @@
}
@FunctionalInterface
- public static interface TriConsumer<A,B,C> {
+ public static interface TriConsumer<A, B, C> {
public void accept(A propName, B propValue, C exception);
}
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index 2ff1d56..601c3e9 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -386,7 +386,7 @@
logger.info("-- testMultipleServers() --");
HttpServletServer server1 = HttpServletServerFactoryInstance.getServerFactory()
- .build("echo-1", false,LOCALHOST, port, "/", true, true);
+ .build("echo-1", false, LOCALHOST, port, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
server1.waitedStart(5000);
diff --git a/pom.xml b/pom.xml
index 7546db0..1b275a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
ONAP policy
================================================================================
Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019-2020 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -122,42 +122,6 @@
</dependency>
</dependencies>
</plugin>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <id>onap-java-style</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <!-- Use Google Java Style Guide:
- https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
- with minor changes -->
- <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
- <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
- <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
- <includeResources>true</includeResources>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <includeTestResources>true</includeTestResources>
- <excludes>
- </excludes>
- <consoleOutput>true</consoleOutput>
- <failsOnViolation>true</failsOnViolation>
- <violationSeverity>warning</violationSeverity>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.oparent</groupId>
- <artifactId>checkstyle</artifactId>
- <version>${oparent.version}</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- </plugin>
</plugins>
</build>
<reporting>
diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
index c5b8c98..2810c7b 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
@@ -108,8 +108,7 @@
if (charsRead > 0) {
builder.append(chars, 0, charsRead);
}
- }
- while (charsRead > 0);
+ } while (charsRead > 0);
return builder.toString();
}
}
diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java b/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java
index e88361e..332e0f6 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java
@@ -44,7 +44,7 @@
* otherwise
*/
public static <T> boolean apply(List<T> providers, Predicate<T> predicate,
- BiConsumer<T,Exception> handleEx) {
+ BiConsumer<T, Exception> handleEx) {
for (T feature : providers) {
try {
diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java b/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java
index 7c5c9cb..998d674 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java
@@ -44,7 +44,7 @@
private ServiceLoader<T> serviceLoader = null;
// use this to ensure that we only use one unique instance of each class
- private static Map<Class<?>,OrderedService> classToSingleton = new HashMap<>();
+ private static Map<Class<?>, OrderedService> classToSingleton = new HashMap<>();
/**
* Constructor - create the 'ServiceLoader' instance.
@@ -86,7 +86,7 @@
// build a list of all of the current implementors
List<T> tmp = new LinkedList<>();
for (T service : serviceLoader) {
- tmp.add((T)getSingleton(service));
+ tmp.add((T) getSingleton(service));
}
// Sort the list according to sequence number, and then alphabetically
diff --git a/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java b/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java
index efbf937..527113d 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/validation/Version.java
@@ -62,8 +62,7 @@
this.major = newVersion.major;
this.minor = newVersion.minor;
this.patch = newVersion.patch;
- }
- else {
+ } else {
this.major = 0;
this.minor = 0;
this.patch = 0;
diff --git a/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyObjectUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyObjectUtilsTest.java
index 83b264f..93b3064 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyObjectUtilsTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyObjectUtilsTest.java
@@ -104,7 +104,7 @@
Map<String, Object> result = PropertyObjectUtils.toObject(props, "");
// @formatter:off
- Map<String,Object> map =
+ Map<String, Object> map =
Map.of("abc",
Arrays.asList(null, "expand.ghi", "expand.def"));
// @formatter:on
@@ -119,7 +119,7 @@
Map<String, Object> result = PropertyObjectUtils.toObject(props, "");
// @formatter:off
- Map<String,Object> map =
+ Map<String, Object> map =
Map.of("object",
Map.of("abc",
Map.of("ghi", "object.jkl")));
@@ -134,7 +134,7 @@
Map<String, Object> result = PropertyObjectUtils.toObject(props, "");
// @formatter:off
- Map<String,Object> map =
+ Map<String, Object> map =
Map.of("array",
Map.of("abc",
List.of(
diff --git a/utils/src/test/java/org/onap/policy/common/utils/properties/exception/PropertyAccessExceptionTest.java b/utils/src/test/java/org/onap/policy/common/utils/properties/exception/PropertyAccessExceptionTest.java
index 27b0e85..ef2051d 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/properties/exception/PropertyAccessExceptionTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/properties/exception/PropertyAccessExceptionTest.java
@@ -34,10 +34,10 @@
*/
@Test
public void testPropertyAccessExceptionStringField() {
- verifyPropertyExceptionStringField_AllPopulated( new PropertyAccessException(PROPERTY, FIELD));
- verifyPropertyExceptionStringField_NullProperty( new PropertyAccessException(null, FIELD));
- verifyPropertyExceptionStringField_NullField( new PropertyAccessException(PROPERTY, null));
- verifyPropertyExceptionStringField_BothNull( new PropertyAccessException(null, null));
+ verifyPropertyExceptionStringField_AllPopulated(new PropertyAccessException(PROPERTY, FIELD));
+ verifyPropertyExceptionStringField_NullProperty(new PropertyAccessException(null, FIELD));
+ verifyPropertyExceptionStringField_NullField(new PropertyAccessException(PROPERTY, null));
+ verifyPropertyExceptionStringField_BothNull(new PropertyAccessException(null, null));
}
/**
diff --git a/utils/src/test/java/org/onap/policy/common/utils/services/FeatureApiUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/services/FeatureApiUtilsTest.java
index 232d340..d111962 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/services/FeatureApiUtilsTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/services/FeatureApiUtilsTest.java
@@ -61,7 +61,7 @@
public void testApplyFeatureFalse() {
List<String> lst = Arrays.asList("falseF1", "exceptF2", "falseF3");
- assertFalse(FeatureApiUtils.apply(lst, pred, (str,ex) -> errors.add(str)));
+ assertFalse(FeatureApiUtils.apply(lst, pred, (str, ex) -> errors.add(str)));
assertEquals(lst.toString(), tried.toString());
assertEquals("[exceptF2]", errors.toString());
}