Fix sonars in apex-pdp #2 69/123669/2
authorJim Hahn <jrh3@att.com>
Fri, 27 Aug 2021 19:24:06 +0000 (15:24 -0400)
committerJim Hahn <jrh3@att.com>
Fri, 27 Aug 2021 20:08:00 +0000 (16:08 -0400)
plugins-events thru plugins-persistence-jpa-eclipselink

Fixed:
- use "var"
- disambiguate method parameter types
- rename parameter

Issue-ID: POLICY-3093
Change-Id: Ife5897015be495403e731754d5862b803a217c87
Signed-off-by: Jim Hahn <jrh3@att.com>
25 files changed:
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcProducer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/main/java/org/onap/policy/apex/plugins/event/carrier/grpc/GrpcCarrierTechnologyParameters.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaConsumer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/KafkaCarrierTechnologyParameters.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerProducer.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-jms/src/main/java/org/onap/policy/apex/plugins/event/protocol/jms/Apex2JmsObjectEventConverter.java
plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/main/java/org/onap/policy/apex/plugins/event/protocol/xml/Apex2XmlEventConverter.java
plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
plugins/plugins-executor/plugins-executor-javascript/src/main/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptExecutor.java
plugins/plugins-executor/plugins-executor-javascript/src/test/java/org/onap/policy/apex/plugins/executor/javascript/JavascriptTaskSelectExecutorTest.java
plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyStateFinalizerExecutor.java
plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskExecutor.java
plugins/plugins-executor/plugins-executor-jruby/src/main/java/org/onap/policy/apex/plugins/executor/jruby/JrubyTaskSelectExecutor.java
plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelStateFinalizerExecutor.java
plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskExecutor.java
plugins/plugins-executor/plugins-executor-mvel/src/main/java/org/onap/policy/apex/plugins/executor/mvel/MvelTaskSelectExecutor.java

index ce00210..fcb743d 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Nordix Foundation.
  *  Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -24,13 +25,11 @@ package org.onap.policy.apex.plugins.event.carrier.grpc;
 import com.google.protobuf.InvalidProtocolBufferException;
 import com.google.protobuf.util.JsonFormat;
 import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
 import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput.Builder;
 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
 import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
 import org.onap.policy.apex.service.engine.event.ApexEventException;
@@ -100,7 +99,7 @@ public class ApexGrpcProducer extends ApexPluginsEventProducer implements CdsPro
         final Object event) {
 
         ExecutionServiceInput executionServiceInput;
-        Builder builder = ExecutionServiceInput.newBuilder();
+        var builder = ExecutionServiceInput.newBuilder();
         try {
             JsonFormat.parser().ignoringUnknownFields().merge((String) event, builder);
             executionServiceInput = builder.build();
@@ -109,7 +108,7 @@ public class ApexGrpcProducer extends ApexPluginsEventProducer implements CdsPro
                 "Incoming Event cannot be converted to ExecutionServiceInput type for gRPC request." + e.getMessage());
         }
         try {
-            CountDownLatch countDownLatch = client.sendRequest(executionServiceInput);
+            var countDownLatch = client.sendRequest(executionServiceInput);
             if (!countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS)) {
                 cdsResponse.set(ExecutionServiceOutput.newBuilder().setStatus(Status.newBuilder()
                     .setErrorMessage(CdsActorConstants.TIMED_OUT).setEventType(EventType.EVENT_COMPONENT_FAILURE))
index f13248e..79a28c6 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Nordix Foundation.
+ *  Modifications Copyright (C) 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.
@@ -84,7 +85,7 @@ public class GrpcCarrierTechnologyParameters extends CarrierTechnologyParameters
      * @throws ApexEventException exception thrown when invalid parameters are provided
      */
     public void validateGrpcParameters(boolean isProducer) throws ApexEventException {
-        StringBuilder errorMessage = new StringBuilder();
+        var errorMessage = new StringBuilder();
         if (isProducer) {
             if (timeout < 1) {
                 errorMessage.append("timeout should have a positive value.\n");
index 4bad4cb..2bca82e 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ *  Modifications Copyright (C) 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.
@@ -25,7 +26,6 @@ import java.util.Properties;
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.Message;
-import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.Session;
 import javax.jms.Topic;
@@ -141,11 +141,11 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message
     @Override
     public void run() {
         // JMS session and message consumer for receiving messages
-        try (final Session jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
+        try (final var jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
             // Create a message consumer for reception of messages and set this class as a message listener
             createMessageConsumer(jmsSession);
         } catch (final Exception exc) {
-            final String errorMessage = "failed to create a JMS session towards the JMS server for receiving messages";
+            final var errorMessage = "failed to create a JMS session towards the JMS server for receiving messages";
             throw new ApexEventRuntimeException(errorMessage, exc);
         }
         // Everything is now set up
@@ -161,7 +161,7 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message
      * @param jmsSession a JMS session
      */
     private void createMessageConsumer(final Session jmsSession) {
-        try (final MessageConsumer messageConsumer = jmsSession.createConsumer(jmsIncomingTopic)) {
+        try (final var messageConsumer = jmsSession.createConsumer(jmsIncomingTopic)) {
             messageConsumer.setMessageListener(this);
 
             // The endless loop that receives events over JMS
@@ -169,8 +169,7 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message
                 ThreadUtilities.sleep(jmsConsumerProperties.getConsumerWaitTime());
             }
         } catch (final Exception exc) {
-            final String errorMessage = "failed to create a JMS message consumer for receiving messages";
-            throw new ApexEventRuntimeException(errorMessage, exc);
+            throw new ApexEventRuntimeException("failed to create a JMS message consumer for receiving messages", exc);
         }
     }
 
@@ -188,8 +187,7 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message
 
             eventReceiver.receiveEvent(new Properties(), jmsMessage);
         } catch (final Exception e) {
-            final String errorMessage = "failed to receive message from JMS";
-            throw new ApexEventRuntimeException(errorMessage, e);
+            throw new ApexEventRuntimeException("failed to receive message from JMS", e);
         }
     }
 
@@ -210,8 +208,7 @@ public class ApexJmsConsumer extends ApexPluginsEventConsumer implements Message
                 connection.close();
             }
         } catch (final Exception e) {
-            final String errorMessage = "close of connection to the JMS server failed";
-            LOGGER.warn(errorMessage, e);
+            LOGGER.warn("close of connection to the JMS server failed", e);
         }
     }
 
index 42bde24..2130939 100644 (file)
@@ -197,7 +197,7 @@ public class ApexJmsProducer implements ApexEventProducer {
     public void sendEvent(final long executionId, final Properties executionProperties, final String eventname,
                     final Object eventObject) {
         // Check if this is a synchronized event, if so we have received a reply
-        final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
+        final var synchronousEventCache = (SynchronousEventCache) peerReferenceMap
                         .get(EventHandlerPeeredMode.SYNCHRONOUS);
         if (synchronousEventCache != null) {
             synchronousEventCache.removeCachedEventToApexIfExists(executionId);
index 3e2f239..42ff67d 100644 (file)
@@ -159,7 +159,7 @@ public class JmsCarrierTechnologyParameters extends CarrierTechnologyParameters
      * @return the jms consumer properties
      */
     private Properties getJmsProperties() {
-        final Properties jmsProperties = new Properties();
+        final var jmsProperties = new Properties();
 
         jmsProperties.put(PROPERTY_INITIAL_CONTEXT_FACTORY, initialContextFactory);
 
index 2957a1a..95379d4 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2019-2020 Nordix Foundation.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -87,9 +88,9 @@ public class ApexKafkaConsumer extends ApexPluginsEventConsumer {
                 try {
                     final ConsumerRecords<String, String> records =
                         kafkaConsumer.poll(kafkaConsumerProperties.getConsumerPollDuration());
-                    for (final ConsumerRecord<String, String> record : records) {
-                        traceIfTraceEnabled(record);
-                        eventReceiver.receiveEvent(new Properties(), record.value());
+                    for (final ConsumerRecord<String, String> dataRecord : records) {
+                        traceIfTraceEnabled(dataRecord);
+                        eventReceiver.receiveEvent(new Properties(), dataRecord.value());
                     }
                 } catch (final Exception e) {
                     LOGGER.debug("error receiving events on thread {}", consumerThread.getName(), e);
@@ -101,12 +102,12 @@ public class ApexKafkaConsumer extends ApexPluginsEventConsumer {
     /**
      * Trace a record if trace is enabled.
      *
-     * @param record the record to trace
+     * @param dataRecord the record to trace
      */
-    private void traceIfTraceEnabled(final ConsumerRecord<String, String> record) {
+    private void traceIfTraceEnabled(final ConsumerRecord<String, String> dataRecord) {
         if (LOGGER.isTraceEnabled()) {
             LOGGER.trace("event received for {} for forwarding to Apex engine : {} {}",
-                this.getClass().getName() + ":" + this.name, record.key(), record.value());
+                this.getClass().getName() + ":" + this.name, dataRecord.key(), dataRecord.value());
         }
     }
 
index 4750172..a599307 100644 (file)
@@ -158,11 +158,11 @@ public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameter
      * @return the kafka producer properties
      */
     public Properties getKafkaProducerProperties() {
-        final Properties retKafkaProps = new Properties();
+        final var retKafkaProps = new Properties();
 
         // Add properties from the Kafka property array
         if (kafkaProperties != null) {
-            for (int i = 0; i < kafkaProperties.length; i++) {
+            for (var i = 0; i < kafkaProperties.length; i++) {
                 retKafkaProps.setProperty(kafkaProperties[i][0], kafkaProperties[i][1]);
             }
         }
@@ -188,11 +188,11 @@ public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameter
      * @return the kafka consumer properties
      */
     public Properties getKafkaConsumerProperties() {
-        final Properties retKafkaProps = new Properties();
+        final var retKafkaProps = new Properties();
 
         // Add properties from the Kafka property array
         if (kafkaProperties != null) {
-            for (int i = 0; i < kafkaProperties.length; i++) {
+            for (var i = 0; i < kafkaProperties.length; i++) {
                 retKafkaProps.setProperty(kafkaProperties[i][0], kafkaProperties[i][1]);
             }
         }
@@ -250,8 +250,8 @@ public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameter
                     "not specified, must be specified as a list of strings");
         }
 
-        BeanValidationResult result = new BeanValidationResult("consumerTopicList", consumerTopicList);
-        int item = 0;
+        var result = new BeanValidationResult("consumerTopicList", consumerTopicList);
+        var item = 0;
         for (final String consumerTopic : consumerTopicList) {
             if (StringUtils.isBlank(consumerTopic)) {
                 result.addResult(ENTRY + item, consumerTopic, ValidationStatus.INVALID, Validated.IS_BLANK);
@@ -272,13 +272,13 @@ public class KafkaCarrierTechnologyParameters extends CarrierTechnologyParameter
             return null;
         }
 
-        BeanValidationResult result = new BeanValidationResult(KAFKA_PROPERTIES, kafkaProperties);
+        var result = new BeanValidationResult(KAFKA_PROPERTIES, kafkaProperties);
 
-        for (int i = 0; i < kafkaProperties.length; i++) {
+        for (var i = 0; i < kafkaProperties.length; i++) {
             final String label = ENTRY + i;
             final String[] kafkaProperty = kafkaProperties[i];
             final List<String> value = (kafkaProperty == null ? null : Arrays.asList(kafkaProperty));
-            final BeanValidationResult result2 = new BeanValidationResult(label, value);
+            final var result2 = new BeanValidationResult(label, value);
 
             if (kafkaProperty == null) {
                 // note: add to result, not result2
index db14006..956345c 100644 (file)
 package org.onap.policy.apex.plugins.event.carrier.restclient;
 
 import java.util.Properties;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
 import lombok.AccessLevel;
 import lombok.Setter;
 import org.apache.commons.lang3.StringUtils;
@@ -148,11 +146,11 @@ public class ApexRestClientConsumer extends ApexPluginsEventConsumer {
         @Override
         public void run() {
             try {
-                final Response response = client.target(restConsumerProperties.getUrl()).request("application/json")
+                final var response = client.target(restConsumerProperties.getUrl()).request("application/json")
                         .headers(restConsumerProperties.getHttpHeadersAsMultivaluedMap()).get();
 
                 // Match the return code
-                Matcher isPass = httpCodeFilterPattern.matcher(String.valueOf(response.getStatus()));
+                var isPass = httpCodeFilterPattern.matcher(String.valueOf(response.getStatus()));
 
                 // Check that status code
                 if (!isPass.matches()) {
@@ -164,7 +162,7 @@ public class ApexRestClientConsumer extends ApexPluginsEventConsumer {
                 }
 
                 // Get the event we received
-                final String eventJsonString = response.readEntity(String.class);
+                final var eventJsonString = response.readEntity(String.class);
 
                 // Check there is content
                 if (StringUtils.isBlank(eventJsonString)) {
index cb6b553..035bd65 100644 (file)
@@ -124,7 +124,7 @@ public class ApexRestClientProducer extends ApexPluginsEventProducer {
 
         NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, untaggedUrl, event.toString());
         // Send the event as a REST request
-        final Response response = sendEventAsRestRequest(untaggedUrl, (String) event);
+        final var response = sendEventAsRestRequest(untaggedUrl, (String) event);
 
         NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, untaggedUrl, response.readEntity(String.class));
 
index c0a43a3..952ebd7 100644 (file)
@@ -30,13 +30,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Optional;
-import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
@@ -154,7 +152,7 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
 
         // Check if HTTP headers has been set
         if (restConsumerProperties.checkHttpHeadersSet()) {
-            final String httpHeaderString = Arrays.deepToString(restConsumerProperties.getHttpHeaders());
+            final var httpHeaderString = Arrays.deepToString(restConsumerProperties.getHttpHeaders());
             LOGGER.debug("REST Requestor consumer has http headers ({}): {}", this.name, httpHeaderString);
         }
 
@@ -201,11 +199,11 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
 
                 // Create a thread to process the REST request and place it on the map of ongoing
                 // requests
-                final RestRequestRunner restRequestRunner = new RestRequestRunner(restRequest);
+                final var restRequestRunner = new RestRequestRunner(restRequest);
                 ongoingRestRequestMap.put(restRequest, restRequestRunner);
 
                 // Start execution of the request
-                final Thread restRequestRunnerThread = new Thread(restRequestRunner);
+                final var restRequestRunnerThread = new Thread(restRequestRunner);
                 restRequestRunnerThread.setName("RestRequestRunner_" + nextRequestRunnerThreadNo);
                 restRequestRunnerThread.start();
             } catch (final InterruptedException e) {
@@ -284,7 +282,7 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
         public void run() {
             // Get the thread for the request
             restRequestThread = Thread.currentThread();
-            Properties inputExecutionProperties = request.getExecutionProperties();
+            var inputExecutionProperties = request.getExecutionProperties();
             String url = restConsumerProperties.getUrl();
             Set<String> names = restConsumerProperties.getKeysFromUrl();
             if (!names.isEmpty() && inputExecutionProperties != null) {
@@ -305,12 +303,12 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
                     NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, request.getEvent().toString());
                 }
                 // Execute the REST request
-                final Response response = sendEventAsRestRequest(url);
+                final var response = sendEventAsRestRequest(url);
                 // Get the event we received
-                final String eventJsonString = response.readEntity(String.class);
+                final var eventJsonString = response.readEntity(String.class);
                 NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, eventJsonString);
                 // Match the return code
-                Matcher isPass = httpCodeFilterPattern.matcher(String.valueOf(response.getStatus()));
+                var isPass = httpCodeFilterPattern.matcher(String.valueOf(response.getStatus()));
 
                 // Check that the request worked
                 if (!isPass.matches()) {
index 3bfde18..ad3d77b 100644 (file)
@@ -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 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.
@@ -171,7 +172,7 @@ public class ApexRestServerConsumer extends ApexPluginsEventConsumer {
                     .entity("{'errorMessage', '" + errorMessage + ", " + e.getMessage() + "'}").build();
         }
 
-        final SynchronousEventCache synchronousEventCache =
+        final var synchronousEventCache =
                 (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
         // Wait until the event is in the cache of events sent to apex
         do {
index 03913e0..f357956 100644 (file)
@@ -118,7 +118,7 @@ public class ApexRestServerProducer implements ApexEventProducer {
         }
 
         // If we are not synchronized, then exit
-        final SynchronousEventCache synchronousEventCache =
+        final var synchronousEventCache =
                 (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
         if (synchronousEventCache == null) {
             return;
index 7f33fe6..cd14f4a 100644 (file)
@@ -100,7 +100,7 @@ public final class Apex2JmsObjectEventConverter implements ApexEventProtocolConv
 
         // Create the Apex event
         // @formatter:off
-        final ApexEvent apexEvent = new ApexEvent(
+        final var apexEvent = new ApexEvent(
                         jmsIncomingObject.getClass().getSimpleName() + eventProtocolParameters.getIncomingEventSuffix(),
                         eventProtocolParameters.getIncomingEventVersion(),
                         jmsIncomingObject.toString().getClass().getPackage().getName(),
index af4b781..f601c4b 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -23,7 +24,6 @@ package org.onap.policy.apex.plugins.event.protocol.xml;
 
 import java.io.ByteArrayInputStream;
 import java.io.StringWriter;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
@@ -34,7 +34,6 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 import org.onap.policy.apex.plugins.event.protocol.xml.jaxb.ObjectFactory;
 import org.onap.policy.apex.plugins.event.protocol.xml.jaxb.XMLApexEvent;
@@ -69,11 +68,11 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
      */
     public Apex2XmlEventConverter() throws ApexEventException {
         try {
-            final URL schemaUrl = ResourceUtils.getUrlResource(MODEL_SCHEMA_NAME);
-            final Schema apexEventSchema =
+            final var schemaUrl = ResourceUtils.getUrlResource(MODEL_SCHEMA_NAME);
+            final var apexEventSchema =
                     SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl);
 
-            final JAXBContext jaxbContext = JAXBContext.newInstance(XMLApexEvent.class);
+            final var jaxbContext = JAXBContext.newInstance(XMLApexEvent.class);
 
             // Set up the unmarshaller to carry out validation
             unmarshaller = jaxbContext.createUnmarshaller();
@@ -121,7 +120,7 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
 
         // Use JAXB to read and verify the event from the XML string
         try {
-            final StreamSource source = new StreamSource(new ByteArrayInputStream(xmlEventString.getBytes()));
+            final var source = new StreamSource(new ByteArrayInputStream(xmlEventString.getBytes()));
             final JAXBElement<XMLApexEvent> rootElement = unmarshaller.unmarshal(source, XMLApexEvent.class);
             xmlApexEvent = rootElement.getValue();
         } catch (final JAXBException e) {
@@ -129,7 +128,7 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
         }
 
         // Create the Apex event
-        final ApexEvent apexEvent = new ApexEvent(xmlApexEvent.getName(), xmlApexEvent.getVersion(),
+        final var apexEvent = new ApexEvent(xmlApexEvent.getName(), xmlApexEvent.getVersion(),
                 xmlApexEvent.getNameSpace(), xmlApexEvent.getSource(), xmlApexEvent.getTarget());
 
         // Set the data on the apex event
@@ -170,13 +169,13 @@ public final class Apex2XmlEventConverter implements ApexEventProtocolConverter
         }
 
         // Create the XML event
-        final XMLApexEvent xmlApexEvent = new XMLApexEvent(apexEvent.getName(), apexEvent.getVersion(),
+        final var xmlApexEvent = new XMLApexEvent(apexEvent.getName(), apexEvent.getVersion(),
                 apexEvent.getNameSpace(), apexEvent.getSource(), apexEvent.getTarget(), xmlDataList);
 
         // Write the event into a DOM document
         try {
             // Marshal the event into XML
-            final StringWriter writer = new StringWriter();
+            final var writer = new StringWriter();
             marshaller.marshal(objectFactory.createXmlApexEvent(xmlApexEvent), writer);
 
             // Return the event as XML in a string
index 922f64f..21afa2e 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
 
 package org.onap.policy.apex.plugins.executor.java;
 
-import java.lang.reflect.Method;
 import java.util.Map;
 import java.util.Properties;
 import org.onap.policy.apex.context.ContextException;
@@ -80,14 +80,14 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor {
         executePre(executionId, executionProperties, incomingFields);
 
         // Check and execute the Java logic
-        boolean returnValue = false;
+        var returnValue = false;
         try {
             // Find and call the method with the signature "public boolean getStateOutput(final
             // StateFinalizerExecutionContext executor) throws ApexException"
             // to invoke the
             // task logic in the Java class
-            final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput",
-                    new Class[] {StateFinalizerExecutionContext.class});
+            final var classes = new Class[] {StateFinalizerExecutionContext.class};
+            final var method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput", classes);
             returnValue = (boolean) method.invoke(stateFinalizerLogicObject, getExecutionContext());
         } catch (final Exception e) {
             LOGGER.error("execute: state finalizer logic failed to run for state finalizer  \"" + getSubject().getId()
index 736249e..da6533f 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2020 Nordix Foundation.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -22,7 +23,6 @@
 
 package org.onap.policy.apex.plugins.executor.java;
 
-import java.lang.reflect.Method;
 import java.util.Map;
 import java.util.Properties;
 import org.onap.policy.apex.context.ContextException;
@@ -83,13 +83,13 @@ public class JavaTaskExecutor extends TaskExecutor {
         executePre(executionId, executionProperties, incomingFields);
 
         // Check and execute the Java logic
-        boolean returnValue = false;
+        var returnValue = false;
         try {
             // Find and call the method with the signature "public boolean getEvent(final TaskExecutionContext executor)
             // throws ApexException" to invoke the
             // task logic in the Java class
-            final Method method =
-                    taskLogicObject.getClass().getDeclaredMethod("getEvent", new Class[] {TaskExecutionContext.class});
+            final var classes = new Class[] {TaskExecutionContext.class};
+            final var method = taskLogicObject.getClass().getDeclaredMethod("getEvent", classes);
             returnValue = (boolean) method.invoke(taskLogicObject, getExecutionContext());
         } catch (final Exception e) {
             LOGGER.error("execute: task logic failed to run for task  \"" + getSubject().getKey().getId() + "\"");
index ee830ca..27207a5 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
 
 package org.onap.policy.apex.plugins.executor.java;
 
-import java.lang.reflect.Method;
 import java.util.Properties;
 import org.onap.policy.apex.context.ContextException;
 import org.onap.policy.apex.core.engine.event.EnEvent;
@@ -84,13 +84,13 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
         executePre(executionId, executionProperties, incomingEvent);
 
         // Check and execute the Java logic
-        boolean returnValue = false;
+        var returnValue = false;
         try {
             // Find and call the method with the signature "public boolean getTask(final TaskSelectionExecutionContext
             // executor)" to invoke the task selection
             // logic in the Java class
-            final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask",
-                    new Class[] {TaskSelectionExecutionContext.class});
+            final var classes = new Class[] {TaskSelectionExecutionContext.class};
+            final var method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask", classes);
             returnValue = (boolean) method.invoke(taskSelectionLogicObject, getExecutionContext());
         } catch (final Exception e) {
             LOGGER.error(
index 344f8c5..18aac64 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -67,7 +68,7 @@ public class JavascriptExecutor {
     public boolean execute(final Object executionContext) throws StateMachineException {
         Object returnObject = null;
 
-        Context context = Context.enter();
+        var context = Context.enter();
         try {
             // Pass the subject context to the Javascript engine
             Scriptable javascriptScope = context.initStandardObjects();
@@ -91,7 +92,7 @@ public class JavascriptExecutor {
     }
 
     private Script compile(String id, String javascriptCode) throws StateMachineException {
-        Context context = Context.enter();
+        var context = Context.enter();
         try {
             // Set up the default values of the context
             context.setOptimizationLevel(DEFAULT_OPTIMIZATION_LEVEL);
index 78ac853..d2bb852 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2020 Nordix Foundation.
+ *  Modifications Copyright (C) 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.
@@ -85,9 +86,8 @@ public class JavascriptTaskSelectExecutorTest {
         state.getTaskSelectionLogic().setLogic("java.lang.String");
         jtse.prepare();
 
-        assertThatThrownBy(() -> {
-            jtse.execute(-1, new Properties(), null);
-        }).isInstanceOf(NullPointerException.class);
+        final var props = new Properties();
+        assertThatThrownBy(() -> jtse.execute(-1, props, null)).isInstanceOf(NullPointerException.class);
 
         AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
         EnEvent event = new EnEvent(axEvent);
index ee172d3..10d93e5 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -89,7 +90,7 @@ public class JrubyStateFinalizerExecutor extends StateFinalizerExecutor {
         container.put("executor", getExecutionContext());
 
         /* Precompiled version */
-        boolean returnValue = false;
+        var returnValue = false;
         final IRubyObject ret = parsedjruby.run();
         if (ret != null) {
             final Boolean retbool = ret.toJava(java.lang.Boolean.class);
index aa57004..f54c2d7 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -90,7 +91,7 @@ public class JrubyTaskExecutor extends TaskExecutor {
         container.put("executor", getExecutionContext());
 
         /* Precompiled version */
-        boolean returnValue = false;
+        var returnValue = false;
         final IRubyObject ret = parsedjruby.run();
         if (ret != null) {
             final Boolean retbool = ret.toJava(java.lang.Boolean.class);
index 97419b0..5f21671 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -93,7 +94,7 @@ public class JrubyTaskSelectExecutor extends TaskSelectExecutor {
         container.put("executor", getExecutionContext());
 
         /* Precompiled version */
-        boolean returnValue = false;
+        var returnValue = false;
         final IRubyObject ret = parsedjruby.run();
         if (ret != null) {
             final Boolean retbool = ret.toJava(java.lang.Boolean.class);
index 5cf0bbb..621bc1a 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -85,7 +86,7 @@ public class MvelStateFinalizerExecutor extends StateFinalizerExecutor {
         // Check and execute the MVEL logic
         argumentNotNull(compiled, "MVEL state finalizer logic not compiled.");
 
-        boolean returnValue = false;
+        var returnValue = false;
         try {
             // Execute the MVEL code
             returnValue =
index 07a287f..9040b5b 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.
@@ -85,7 +86,7 @@ public class MvelTaskExecutor extends TaskExecutor {
 
         // Check and execute the MVEL logic
         argumentNotNull(compiled, "MVEL task not compiled.");
-        boolean returnValue = false;
+        var returnValue = false;
 
         try {
             // Execute the MVEL code
index 7f1e475..4f39ae0 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -86,7 +87,7 @@ public class MvelTaskSelectExecutor extends TaskSelectExecutor {
         // Check and execute the MVEL logic
         argumentNotNull(compiled, "MVEL task not compiled.");
 
-        boolean returnValue = false;
+        var returnValue = false;
         try {
             // Execute the MVEL code
             returnValue =