summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2021-08-27 16:53:11 -0400
committerAjith Sreekumar <ajith.sreekumar@bell.ca>2021-08-31 10:14:34 +0000
commit9ee4561bcd28b7199fd1ffed118f122a8435203a (patch)
tree49f07ddc8d082f6028fb53dbfcfeb654b79a55a3
parent795bd98b7459fd677e06354ea054c8922821522b (diff)
Fix sonar issues in apex-pdp
Issue-ID: POLICY-3077 Change-Id: Id5e7c2ddada2bac3b73fe543f9adade6f9b83e6c Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java7
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java5
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java7
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java7
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java9
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java5
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java6
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java3
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java3
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java3
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/monitoring/EventMonitor.java11
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/classes/ClassUtils.java12
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/compile/singleclass/SingleClassBuilder.java5
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java5
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java5
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java11
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java3
-rw-r--r--core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java6
18 files changed, 64 insertions, 49 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
index 431c38789..9f1847543 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -53,8 +54,8 @@ public class DistributorFactory {
Assertions.argumentOfClassNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
// Get the class for the distributor using reflection
- final DistributorParameters distributorParameters =
- ParameterService.get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ final var distributorParameters =
+ (DistributorParameters) ParameterService.get(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
final String pluginClass = distributorParameters.getPluginClass();
Object contextDistributorObject = null;
try {
@@ -73,7 +74,7 @@ public class DistributorFactory {
}
// The context Distributor to return
- final Distributor contextDistributor = (Distributor) contextDistributorObject;
+ final var contextDistributor = (Distributor) contextDistributorObject;
// Lock and load the context distributor
contextDistributor.init(key);
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
index e98e66148..bd31059f7 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/distribution/DistributorFlushTimerTask.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -64,8 +65,8 @@ public class DistributorFlushTimerTask extends TimerTask {
this.contextDistributor = contextDistributor;
// Set the period for persistence flushing
- final PersistorParameters persistorParameters = ParameterService
- .get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ final var persistorParameters =
+ (PersistorParameters) ParameterService.get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
flushPeriod = persistorParameters.getFlushPeriod();
// Set up the timer
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
index 923c83979..9aac801a3 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/locking/LockManagerFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -50,8 +51,8 @@ public class LockManagerFactory {
public LockManager createLockManager(final AxArtifactKey key) throws ContextException {
LOGGER.entry("Lock Manager factory, key=" + key);
- final LockManagerParameters lockManagerParameters =
- ParameterService.get(ContextParameterConstants.LOCKING_GROUP_NAME);
+ final var lockManagerParameters =
+ (LockManagerParameters) ParameterService.get(ContextParameterConstants.LOCKING_GROUP_NAME);
// Get the class for the lock manager using reflection
Object lockManagerObject = null;
@@ -76,7 +77,7 @@ public class LockManagerFactory {
}
// The context lock manager to return
- final LockManager lockManager = (LockManager) lockManagerObject;
+ final var lockManager = (LockManager) lockManagerObject;
// Lock and load (OK sorry!!!) the lock manager
lockManager.init(key);
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
index fe06d2fdb..31a31b51f 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/persistence/PersistorFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -51,8 +52,8 @@ public class PersistorFactory {
LOGGER.entry("persistor factory, key=" + key);
Assertions.argumentOfClassNotNull(key, ContextException.class, "Parameter \"key\" may not be null");
- final PersistorParameters persistorParameters =
- ParameterService.get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ final var persistorParameters =
+ (PersistorParameters) ParameterService.get(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
// Get the class for the persistor using reflection
Object persistorObject = null;
@@ -75,7 +76,7 @@ public class PersistorFactory {
}
// The persistor to return
- final Persistor persistor = (Persistor) persistorObject;
+ final var persistor = (Persistor) persistorObject;
// Lock and load the persistor
persistor.init(key);
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
index a5fa26870..08289e642 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -24,7 +25,6 @@ package org.onap.policy.apex.context.impl.schema;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
-import org.onap.policy.apex.context.parameters.SchemaHelperParameters;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -70,10 +70,11 @@ public class SchemaHelperFactory {
}
// Get the schema class using the parameter service
- final SchemaParameters schemaParameters = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ final var schemaParameters =
+ (SchemaParameters) ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
// Get the class for the schema helper from the schema parameters
- final SchemaHelperParameters schemaHelperParameters =
+ final var schemaHelperParameters =
schemaParameters.getSchemaHelperParameters(schema.getSchemaFlavour());
if (schemaHelperParameters == null) {
final var resultString = "context schema helper parameters not found for context schema \""
@@ -103,7 +104,7 @@ public class SchemaHelperFactory {
}
// The context schema helper to return
- final SchemaHelper schemaHelper = (SchemaHelper) schemaHelperObject;
+ final var schemaHelper = (SchemaHelper) schemaHelperObject;
// Lock and load the schema helper
schemaHelper.init(owningEntityKey.getKey(), schema);
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
index 7d67788b6..f601062bb 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -234,10 +235,10 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
* @return the GSON instance
*/
private Gson getGson() {
- GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting();
+ var gsonBuilder = new GsonBuilder().setPrettyPrinting();
// Get the Java schema helper parameters from the parameter service
- SchemaParameters schemaParameters = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ var schemaParameters = (SchemaParameters) ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
JavaSchemaHelperParameters javaSchemaHelperParmeters =
(JavaSchemaHelperParameters) schemaParameters.getSchemaHelperParameterMap().get("Java");
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java
index 3f6d6cfe6..6cbc04678 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutor.java
@@ -93,7 +93,7 @@ public class StateMachineExecutor implements Executor<EnEvent, Collection<EnEven
StateExecutor lastExecutor = null;
for (final AxState state : axPolicy.getStateMap().values()) {
// Create a state executor for this state and add its context (the state)
- final StateExecutor stateExecutor = new StateExecutor(executorFactory);
+ final var stateExecutor = new StateExecutor(executorFactory);
stateExecutor.setContext(this, state, internalContext);
// Update the next executor on the last executor
@@ -140,8 +140,8 @@ public class StateMachineExecutor implements Executor<EnEvent, Collection<EnEven
// Get the first state of the state machine and define a state output that starts state
// execution
- StateExecutor stateExecutor = firstExecutor;
- StateOutput stateOutput = new StateOutput(new AxStateOutput(firstExecutor.getSubject().getKey(),
+ var stateExecutor = firstExecutor;
+ var stateOutput = new StateOutput(new AxStateOutput(firstExecutor.getSubject().getKey(),
incomingEvent.getKey(), firstExecutor.getSubject().getKey()), incomingEvent);
while (true) {
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
index eb5f5f35d..12e350390 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContext.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -150,7 +151,7 @@ public class StateFinalizerExecutionContext extends AbstractExecutionContext {
*/
public ContextAlbum getContextAlbum(final String contextAlbumName) {
// Find the context album
- final ContextAlbum foundContextAlbum = context.get(contextAlbumName);
+ final var foundContextAlbum = context.get(contextAlbumName);
// Check if the context album exists
if (foundContextAlbum != null) {
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
index 69d51c45a..c79e907d9 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContext.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -138,7 +139,7 @@ public class TaskSelectionExecutionContext extends AbstractExecutionContext {
*/
public ContextAlbum getContextAlbum(final String contextAlbumName) {
// Find the context album
- final ContextAlbum foundContextAlbum = context.get(contextAlbumName);
+ final var foundContextAlbum = context.get(contextAlbumName);
// Check if the context album exists
if (foundContextAlbum != null) {
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
index e37d074b6..9dc841f48 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/executor/impl/ExecutorFactoryImpl.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -117,7 +118,7 @@ public class ExecutorFactoryImpl implements ExecutorFactory {
public TaskExecutor getTaskExecutor(final Executor<?, ?, ?, ?> parentExecutor, final AxTask task,
final ApexInternalContext context) {
// Create task executor
- final TaskExecutor taskExecutor = (TaskExecutor) createExecutor(task.getTaskLogic().getLogicFlavour(),
+ final var taskExecutor = (TaskExecutor) createExecutor(task.getTaskLogic().getLogicFlavour(),
taskExecutorPluginClassMap.get(task.getTaskLogic().getLogicFlavour()), TaskExecutor.class);
taskExecutor.setParameters(implementationParameterMap.get(task.getTaskLogic().getLogicFlavour()));
taskExecutor.setContext(parentExecutor, task, context);
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/monitoring/EventMonitor.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/monitoring/EventMonitor.java
index de2639dcb..ca564ca81 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/monitoring/EventMonitor.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/monitoring/EventMonitor.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -44,7 +45,7 @@ public class EventMonitor {
* @param userArtifactStack the keys of the artifacts using the event at the moment
*/
public void monitorGet(final AxField eventParameter, final Object value, final AxConcept[] userArtifactStack) {
- String monitorGetString = monitor("GET", userArtifactStack, eventParameter, value);
+ var monitorGetString = monitor("GET", userArtifactStack, eventParameter, value);
LOGGER.trace(monitorGetString);
}
@@ -56,7 +57,7 @@ public class EventMonitor {
* @param userArtifactStack the keys of the artifacts using the event at the moment
*/
public void monitorSet(final AxField eventParameter, final Object value, final AxConcept[] userArtifactStack) {
- String monitorSetString = monitor("SET", userArtifactStack, eventParameter, value);
+ var monitorSetString = monitor("SET", userArtifactStack, eventParameter, value);
LOGGER.trace(monitorSetString);
}
@@ -69,7 +70,7 @@ public class EventMonitor {
*/
public void monitorRemove(final AxField eventParameter, final Object removedValue,
final AxConcept[] userArtifactStack) {
- String monitorRemoveString = monitor("REMOVE", userArtifactStack, eventParameter, removedValue);
+ var monitorRemoveString = monitor("REMOVE", userArtifactStack, eventParameter, removedValue);
LOGGER.trace(monitorRemoveString);
}
@@ -84,13 +85,13 @@ public class EventMonitor {
*/
private String monitor(final String preamble, final AxConcept[] userArtifactStack, final AxField eventParameter,
final Object value) {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(preamble);
builder.append(",[");
if (userArtifactStack != null) {
- boolean first = true;
+ var first = true;
for (final AxConcept stackKey : userArtifactStack) {
if (first) {
first = false;
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/classes/ClassUtils.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/classes/ClassUtils.java
index e3a51f085..49e7d1e2e 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/classes/ClassUtils.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/classes/ClassUtils.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -26,7 +27,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
@@ -72,7 +72,7 @@ public final class ClassUtils {
try {
// The library path for predefined classes in Java
- String sunBootLibraryPathString = System.getProperty(SUN_BOOT_LIBRARY_PATH);
+ var sunBootLibraryPathString = System.getProperty(SUN_BOOT_LIBRARY_PATH);
// Check it exists and has a "lib" in it
if (sunBootLibraryPathString != null && sunBootLibraryPathString.contains(LIBRARAY_PATH_TOKEN)) {
@@ -80,7 +80,7 @@ public final class ClassUtils {
sunBootLibraryPathString = sunBootLibraryPathString.substring(0,
sunBootLibraryPathString.lastIndexOf(LIBRARAY_PATH_TOKEN) + LIBRARAY_PATH_TOKEN.length());
- final File bootLibraryFile = new File(sunBootLibraryPathString);
+ final var bootLibraryFile = new File(sunBootLibraryPathString);
// The set used to hold class names is populated with predefined Java classes
classNameSet.addAll(processDir(bootLibraryFile, ""));
}
@@ -96,7 +96,7 @@ public final class ClassUtils {
if (url == null || url.getFile() == null) {
continue;
}
- final File urlFile = new File(url.getFile());
+ final var urlFile = new File(url.getFile());
// Directories may contain ".class" files
if (urlFile.isDirectory()) {
classNameSet.addAll(processDir(urlFile, url.getFile()));
@@ -121,7 +121,7 @@ public final class ClassUtils {
return urls;
}
- Method mmethod = nullclassloader.getMethod("getBootstrapClassPath");
+ var mmethod = nullclassloader.getMethod("getBootstrapClassPath");
if (mmethod == null) {
return urls;
}
@@ -234,7 +234,7 @@ public final class ClassUtils {
return classPathSet;
}
// JARs are ZIP files
- final ZipInputStream zip = new ZipInputStream(jarInputStream);
+ final var zip = new ZipInputStream(jarInputStream);
// Iterate over each entry in the JAR
for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/compile/singleclass/SingleClassBuilder.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/compile/singleclass/SingleClassBuilder.java
index 5cc3f21c7..783ac4cac 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/compile/singleclass/SingleClassBuilder.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/java/compile/singleclass/SingleClassBuilder.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -75,7 +76,7 @@ public class SingleClassBuilder {
final DiagnosticCollector<JavaFileObject> diagnosticListener = new DiagnosticCollector<>();
// Get the Java compiler
- final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ final var compiler = ToolProvider.getSystemJavaCompiler();
// Set up the target file manager and call the compiler
singleFileManager = new SingleFileManager(compiler, new SingleClassByteCodeFileObject(className));
@@ -84,7 +85,7 @@ public class SingleClassBuilder {
// Check if the compilation worked
if (Boolean.FALSE.equals(task.call())) {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
for (final Diagnostic<? extends JavaFileObject> diagnostic : diagnosticListener.getDiagnostics()) {
builder.append("code:");
builder.append(diagnostic.getCode());
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java
index 1bc100084..0cdf76ffc 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/impl/ws/RawMessageHandler.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -92,8 +93,8 @@ public class RawMessageHandler<M> implements WebSocketMessageListener<M>, Runnab
// the queue
// processing thread
- try (final ByteArrayInputStream stream = new ByteArrayInputStream(dataByteBuffer.array());
- final ObjectInputStream ois = new ObjectInputStream(stream)) {
+ try (final var stream = new ByteArrayInputStream(dataByteBuffer.array());
+ final var ois = new ObjectInputStream(stream)) {
@SuppressWarnings("unchecked")
final MessageHolder<M> messageHolder = (MessageHolder<M>) ois.readObject();
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
index 55b2e36ff..8b6d0c6a8 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/stringmessaging/WsStringMessageServer.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -69,14 +70,14 @@ public class WsStringMessageServer implements WsStringMessager {
LOGGER.entry("web socket event consumer server starting . . .");
if (LOGGER.isDebugEnabled()) {
- String lanaddress = "unknown";
+ var lanaddress = "unknown";
try {
lanaddress = MessagingUtils.getLocalHostLanAddress().getHostAddress();
} catch (final UnknownHostException ignore) {
LOGGER.debug("Failed to find name of local address name", ignore);
}
LOGGER.debug("web socket string message server LAN address=" + lanaddress);
- String hostaddress = "unknown";
+ var hostaddress = "unknown";
try {
hostaddress = InetAddress.getLocalHost().getHostAddress();
} catch (final UnknownHostException ignore) {
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java
index ba84ca069..071a6cfde 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/messaging/util/MessagingUtils.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -105,7 +106,7 @@ public final class MessagingUtils {
* @return true if port is available
*/
public static boolean isPortAvailable(final int port) {
- try (final Socket socket = new Socket("localhost", port)) {
+ try (final var socket = new Socket("localhost", port)) {
return false;
} catch (final IOException ignoredException) {
LOGGER.trace("Port {} is available", port, ignoredException);
@@ -193,13 +194,13 @@ public final class MessagingUtils {
// At this point, we did not find a non-loopback address.
// Fall back to returning whatever InetAddress.getLocalHost()
// returns...
- final InetAddress jdkSuppliedAddress = InetAddress.getLocalHost();
+ final var jdkSuppliedAddress = InetAddress.getLocalHost();
if (jdkSuppliedAddress == null) {
throw new UnknownHostException("The JDK InetAddress.getLocalHost() method unexpectedly returned null.");
}
return jdkSuppliedAddress;
} catch (final Exception e) {
- final UnknownHostException unknownHostException =
+ final var unknownHostException =
new UnknownHostException("Failed to determine LAN address: " + e);
unknownHostException.initCause(e);
throw unknownHostException;
@@ -214,8 +215,8 @@ public final class MessagingUtils {
*/
public static byte[] serializeObject(final Object object) {
LOGGER.entry(object.getClass().getName());
- final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- try (ObjectOutputStream oos = new ObjectOutputStream(bytesOut)) {
+ final var bytesOut = new ByteArrayOutputStream();
+ try (var oos = new ObjectOutputStream(bytesOut)) {
oos.writeObject(object);
} catch (final IOException e) {
LOGGER.warn("error on object serialization", e);
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
index dd8b8294f..9345abaaa 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -71,7 +72,7 @@ public class ApplicationThreadFactory implements ThreadFactory {
* @param threadPriority the thread priority
*/
public ApplicationThreadFactory(final String nameLocal, final long stackSize, final int threadPriority) {
- final SecurityManager s = System.getSecurityManager();
+ final var s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
name = APPLICATION_NAME + nameLocal + HYPHEN + NEXT_POOL_NUMBER.getAndIncrement();
this.stackSize = stackSize;
diff --git a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java
index f20907370..2f863d0e3 100644
--- a/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java
+++ b/core/core-infrastructure/src/main/java/org/onap/policy/apex/core/infrastructure/xml/XPathReader.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -26,7 +27,6 @@ import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.slf4j.ext.XLogger;
@@ -74,7 +74,7 @@ public class XPathReader {
private void init() {
try {
LOGGER.info("Initializing XPath reader");
- DocumentBuilderFactory df = DocumentBuilderFactory.newInstance();
+ var df = DocumentBuilderFactory.newInstance();
df.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
df.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
df.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
@@ -106,7 +106,7 @@ public class XPathReader {
*/
public Object read(final String expression, final QName returnType) {
try {
- final XPathExpression xPathExpression = xpath.compile(expression);
+ final var xPathExpression = xpath.compile(expression);
return xPathExpression.evaluate(xmlDocument, returnType);
} catch (final XPathExpressionException ex) {
LOGGER.error("Failed to read XML file for XPath processing, reason:\n" + ex.getMessage(), ex);