summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaka Cho <takamune.cho@att.com>2021-08-17 14:23:26 -0400
committerTaka Cho <takamune.cho@att.com>2021-08-20 17:16:49 -0400
commitbf06e83f40cdbfcfc1428040bf8fa58a518cdea4 (patch)
tree6bf66e14c5e340f4faa8e08cf7404e40cc6e4096
parent172f990bd92e1441eca6dd161458efddb674b2fc (diff)
sonar fix for clamp
- bug: added InterruptedException for sleep - vulns: two false positve - removed some unused import - changed to use var for local variable Issue-ID: POLICY-3452 Change-Id: I8b4be1378a2aad8f68562b63f70853832673ce97 Signed-off-by: Taka Cho <takamune.cho@att.com>
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java6
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java4
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java19
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java24
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java6
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java3
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java8
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java8
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlHttpMessageConverter.java8
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java4
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RequestResponseLoggingFilter.java8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java4
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java4
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java4
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RequestResponseLoggingFilter.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java1
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/Loop.java6
21 files changed, 89 insertions, 52 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
index c5ce99677..956f1db02 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaClElementStatistics.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -139,7 +141,7 @@ public class JpaClElementStatistics extends PfConcept implements PfAuthorative<C
@Override
public ClElementStatistics toAuthorative() {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
+ var clElementStatistics = new ClElementStatistics();
clElementStatistics.setId(UUID.fromString(getKey().getReferenceKey().getLocalName()));
clElementStatistics.setTimeStamp(key.getInstant());
clElementStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
index 911a52089..22773e064 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopElement.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -152,7 +154,7 @@ public class JpaControlLoopElement extends PfConcept implements PfAuthorative<Co
@Override
public ControlLoopElement toAuthorative() {
- ControlLoopElement element = new ControlLoopElement();
+ var element = new ControlLoopElement();
element.setId(UUID.fromString(getKey().getLocalName()));
element.setDefinition(new ToscaConceptIdentifier(definition));
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
index b97f9ed69..2e5188abe 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipantStatistics.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -189,7 +191,7 @@ public class JpaParticipantStatistics extends PfConcept implements PfAuthorative
@Override
public ParticipantStatistics toAuthorative() {
- ParticipantStatistics participantStatistics = new ParticipantStatistics();
+ var participantStatistics = new ParticipantStatistics();
participantStatistics.setTimeStamp(key.getTimeStamp().toInstant());
participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
participantStatistics.setState(state);
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java
index 0f065e9e6..d38fa4bb2 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -23,10 +25,6 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
/**
* Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to controlloop runtime.
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
index 74c1ee5c1..5cf1b0df9 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -115,7 +117,7 @@ public class ClampHttpClient extends AbstractHttpClient {
if (loop == null || loop.getComponents() == null || loop.getComponents().isEmpty()) {
return STATUS_NOT_FOUND;
}
- ExternalComponent externalComponent = loop.getComponents().get("DCAE");
+ var externalComponent = loop.getComponents().get("DCAE");
if (externalComponent == null || externalComponent.getComponentState() == null) {
return STATUS_NOT_FOUND;
}
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
index 08ebd194a..b80fbfb5b 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -93,7 +95,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
ControlLoopOrderedState newState) {
switch (newState) {
case UNINITIALISED:
- Loop loop = clampClient.getstatus(LOOP);
+ var loop = clampClient.getstatus(LOOP);
if (loop != null) {
clampClient.undeploy(LOOP);
intermediaryApi.updateControlLoopElementState(controlLoopElementId, newState,
@@ -113,7 +115,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
}
private Loop getStatus() throws PfModelException {
- Loop loop = clampClient.getstatus(LOOP);
+ var loop = clampClient.getstatus(LOOP);
if (loop == null) {
loop = clampClient.create(LOOP, TEMPLATE);
}
@@ -143,12 +145,12 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
public void controlLoopElementUpdate(ControlLoopElement element, ToscaNodeTemplate nodeTemplate)
throws PfModelException {
try {
- Loop loop = getStatus();
+ var loop = getStatus();
if (BLUEPRINT_DEPLOYED.equals(ClampHttpClient.getStatusCode(loop))) {
deploy();
- boolean deployedFlag = false;
- for (int i = 0; i < checkCount; i++) {
+ var deployedFlag = false;
+ for (var i = 0; i < checkCount; i++) {
// sleep 10 seconds
TimeUnit.SECONDS.sleep(secCount);
loop = getStatus();
@@ -168,6 +170,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
}
} catch (PfModelException e) {
throw e;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new PfModelException(null, e.getMessage(), e);
} catch (Exception e) {
throw new PfModelException(null, e.getMessage(), e);
}
@@ -180,9 +185,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
*/
@Override
public void handleStatistics(UUID controlLoopElementId) {
- ControlLoopElement clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
+ var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
if (clElement != null) {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
+ var clElementStatistics = new ClElementStatistics();
clElementStatistics.setControlLoopState(clElement.getState());
clElementStatistics.setTimeStamp(Instant.now());
intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java
index 8a7f403f4..74728a974 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -96,7 +98,7 @@ class ControlLoopElementHandlerTest {
ControlLoopElementHandler controlLoopElementHandler =
new ControlLoopElementHandler(clampClient, consulClient, commonTestData.getParticipantDcaeParameters());
- when(clampClient.getstatus(eq(LOOP))).thenReturn(new Loop());
+ when(clampClient.getstatus(LOOP)).thenReturn(new Loop());
ParticipantIntermediaryApi intermediaryApi = mock(ParticipantIntermediaryApi.class);
controlLoopElementHandler.setIntermediaryApi(intermediaryApi);
@@ -105,7 +107,7 @@ class ControlLoopElementHandlerTest {
controlLoopElementHandler.controlLoopElementStateChange(controlLoopElementId, ControlLoopState.PASSIVE,
ControlLoopOrderedState.UNINITIALISED);
- verify(clampClient).undeploy(eq(LOOP));
+ verify(clampClient).undeploy(LOOP);
controlLoopElementHandler.handleStatistics(controlLoopElementId);
assertThat(intermediaryApi.getControlLoopElement(controlLoopElementId)).isNull();
}
@@ -114,12 +116,12 @@ class ControlLoopElementHandlerTest {
void testCreate_ControlLoopElementUpdate() throws PfModelException, JSONException, CoderException {
ClampHttpClient clampClient = spy(mock(ClampHttpClient.class));
Loop loopDeployed = CODER.convert(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED), Loop.class);
- when(clampClient.create(eq(LOOP), eq(TEMPLATE))).thenReturn(loopDeployed);
- when(clampClient.deploy(eq(LOOP))).thenReturn(true);
+ when(clampClient.create(LOOP, TEMPLATE)).thenReturn(loopDeployed);
+ when(clampClient.deploy(LOOP)).thenReturn(true);
Loop loopInstalled =
CODER.convert(CommonTestData.createJsonStatus(MICROSERVICE_INSTALLED_SUCCESSFULLY), Loop.class);
- when(clampClient.getstatus(eq(LOOP))).thenReturn(null, loopInstalled);
+ when(clampClient.getstatus(LOOP)).thenReturn(null, loopInstalled);
ConsulDcaeHttpClient consulClient = spy(mock(ConsulDcaeHttpClient.class));
when(consulClient.deploy(any(String.class), any(String.class))).thenReturn(true);
@@ -139,9 +141,9 @@ class ControlLoopElementHandlerTest {
controlLoopDefinition.getToscaTopologyTemplate().getNodeTemplates()
.get("org.onap.domain.pmsh.PMSH_DCAEMicroservice"));
- verify(clampClient).create(eq(LOOP), eq(TEMPLATE));
+ verify(clampClient).create(LOOP, TEMPLATE);
verify(consulClient).deploy(any(String.class), any(String.class));
- verify(clampClient).deploy(eq(LOOP));
+ verify(clampClient).deploy(LOOP);
}
@Test
@@ -150,8 +152,8 @@ class ControlLoopElementHandlerTest {
Loop loopDeployed = CODER.convert(CommonTestData.createJsonStatus(BLUEPRINT_DEPLOYED), Loop.class);
Loop loopInstalled =
CODER.convert(CommonTestData.createJsonStatus(MICROSERVICE_INSTALLED_SUCCESSFULLY), Loop.class);
- when(clampClient.getstatus(eq(LOOP))).thenReturn(loopDeployed, loopInstalled);
- when(clampClient.deploy(eq(LOOP))).thenReturn(true);
+ when(clampClient.getstatus(LOOP)).thenReturn(loopDeployed, loopInstalled);
+ when(clampClient.deploy(LOOP)).thenReturn(true);
ConsulDcaeHttpClient consulClient = spy(mock(ConsulDcaeHttpClient.class));
when(consulClient.deploy(any(String.class), any(String.class))).thenReturn(true);
@@ -171,8 +173,8 @@ class ControlLoopElementHandlerTest {
controlLoopDefinition.getToscaTopologyTemplate().getNodeTemplates()
.get("org.onap.domain.pmsh.PMSH_DCAEMicroservice"));
- verify(clampClient, times(0)).create(eq(LOOP), eq(TEMPLATE));
+ verify(clampClient, times(0)).create(LOOP, TEMPLATE);
verify(consulClient).deploy(any(String.class), any(String.class));
- verify(clampClient).deploy(eq(LOOP));
+ verify(clampClient).deploy(LOOP);
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java
index 97adfde88..54627d557 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java
@@ -2,6 +2,8 @@
* ========================LICENSE_START=================================
* Copyright (C) 2021 Nordix Foundation. 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.
* You may obtain a copy of the License at
@@ -18,10 +20,6 @@
package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations;
-import org.apache.catalina.connector.Connector;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
index b38fbeb81..6a1b98654 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
@@ -2,6 +2,8 @@
* ========================LICENSE_START=================================
* Copyright (C) 2021 Nordix Foundation. 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.
* You may obtain a copy of the License at
@@ -25,7 +27,6 @@ import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
index 975671705..ed53d0352 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
@@ -2,6 +2,8 @@
* ========================LICENSE_START=================================
* Copyright (C) 2021 Nordix Foundation. 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.
* You may obtain a copy of the License at
@@ -168,7 +170,7 @@ public class ChartStore {
try (var out = new PrintStream(new FileOutputStream(getFile(chart)))) {
out.print(STANDARD_CODER.encode(chart));
} catch (Exception exc) {
- LOGGER.warn("Could not store chart: {} {}", chart.getChartId(), exc);
+ LOGGER.warn("Could not store chart: {}", chart.getChartId(), exc);
}
}
@@ -179,11 +181,11 @@ public class ChartStore {
private synchronized void restoreFromLocalFileSystem() {
try {
- Path localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory());
+ var localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory());
Files.createDirectories(localChartDirectoryPath);
restoreFromLocalFileSystem(localChartDirectoryPath);
} catch (Exception ioe) {
- LOGGER.warn("Could not restore charts from local file system: {}", ioe);
+ LOGGER.warn("Could not restore charts from local file system", ioe);
}
}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java
index 60515048e..0e19ea33e 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -98,7 +100,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
}
}
- private void deletePolicyData(UUID controlLoopElementId, ControlLoopOrderedState newState) throws PfModelException {
+ private void deletePolicyData(UUID controlLoopElementId, ControlLoopOrderedState newState) {
// Delete all policies of this controlLoop from policy framework
for (Entry<String, String> policy : policyMap.entrySet()) {
apiHttpClient.deletePolicy(policy.getKey(), policy.getValue());
@@ -155,9 +157,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
*/
@Override
public void handleStatistics(UUID controlLoopElementId) throws PfModelException {
- ControlLoopElement clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
+ var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
if (clElement != null) {
- ClElementStatistics clElementStatistics = new ClElementStatistics();
+ var clElementStatistics = new ClElementStatistics();
clElementStatistics.setControlLoopState(clElement.getState());
clElementStatistics.setTimeStamp(Instant.now());
intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlHttpMessageConverter.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlHttpMessageConverter.java
index 4c8d324c6..3e1059835 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlHttpMessageConverter.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/config/YamlHttpMessageConverter.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -45,15 +47,15 @@ public class YamlHttpMessageConverter<T> extends AbstractHttpMessageConverter<T>
@Override
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
- Yaml yaml = new Yaml();
+ var yaml = new Yaml();
return yaml.loadAs(inputMessage.getBody(), clazz);
}
@Override
protected void writeInternal(T t, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
- Yaml yaml = new Yaml();
- try (OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) {
+ var yaml = new Yaml();
+ try (var writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) {
yaml.dump(t, writer);
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java
index 562bbd13e..34b212305 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/GlobalControllerExceptionHandler.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -41,7 +43,7 @@ public class GlobalControllerExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<CommissioningResponse> handleBadRequest(ControlLoopException ex) {
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(ex.getErrorResponse().getErrorMessage());
return ResponseEntity.status(ex.getErrorResponse().getResponseCode().getStatusCode()).body(resp);
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
index 695ae06a8..75546196a 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/ParticipantErrorController.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -76,7 +78,7 @@ public class ParticipantErrorController implements ErrorController {
Map<String, Object> map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request),
ErrorAttributeOptions.defaults());
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
final Object error = map.get("error");
if (error != null) {
sb.append(error.toString() + " ");
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RequestResponseLoggingFilter.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RequestResponseLoggingFilter.java
index 3aaeeaf72..9626421e8 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RequestResponseLoggingFilter.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/RequestResponseLoggingFilter.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -50,8 +52,12 @@ public class RequestResponseLoggingFilter implements Filter {
HttpServletResponse res = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;
+ /*
+ * Disabling sonar because of ONAP requires the request ID to be copied from the request
+ * to the response, and just a simulator used during testing.
+ */
String requestId = req.getHeader(REQUEST_ID_NAME);
- res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString());
+ res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR
res.addHeader(VERSION_MINOR_NAME, "0");
res.addHeader(VERSION_PATCH_NAME, "0");
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java
index 262b21630..4b7224938 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantAckListener.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -22,8 +24,6 @@ package org.onap.policy.clamp.controlloop.participant.intermediary.comm;
import java.util.function.Consumer;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessage;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.listeners.ScoListener;
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
index f2421141a..daf9ebe39 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -100,7 +102,7 @@ public class ControlLoopHandler {
LOGGER.warn("Cannot update Control loop element state, id is null");
}
- ControlLoopAck controlLoopStateChangeAck =
+ var controlLoopStateChangeAck =
new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK);
ControlLoopElement clElement = elementsOnThisParticipant.get(id);
if (clElement != null) {
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
index 6dcf93357..f887f6578 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -275,7 +277,7 @@ public class ParticipantHandler implements Closeable {
this.participantStatistics.setHealthStatus(healthStatus);
this.participantStatistics.setTimeStamp(Instant.now());
- ParticipantStatus heartbeat = new ParticipantStatus();
+ var heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(participantId);
heartbeat.setParticipantStatistics(participantStatistics);
heartbeat.setParticipantType(participantType);
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RequestResponseLoggingFilter.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RequestResponseLoggingFilter.java
index eb08391a9..0dd00e766 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RequestResponseLoggingFilter.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/web/RequestResponseLoggingFilter.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
* You may obtain a copy of the License at
@@ -50,8 +52,12 @@ public class RequestResponseLoggingFilter implements Filter {
HttpServletResponse res = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;
+ /*
+ * Disabling sonar because of ONAP requires the request ID to be copied from the request
+ * to the response.
+ */
String requestId = req.getHeader(REQUEST_ID_NAME);
- res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString());
+ res.addHeader(REQUEST_ID_NAME, requestId != null ? requestId : UUID.randomUUID().toString()); // NOSONAR
res.addHeader(VERSION_MINOR_NAME, "0");
res.addHeader(VERSION_PATCH_NAME, "0");
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java
index 4145844a2..5d09c065a 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java
@@ -185,7 +185,6 @@ public class LoggingUtils {
* @param serviceName service name
*/
public void entering(HttpServletRequest request, String serviceName) {
- // MDC.clear();
checkNotNull(request);
// Extract MDC values from standard HTTP headers.
final String requestId =
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/Loop.java b/runtime/src/main/java/org/onap/policy/clamp/loop/Loop.java
index 99d8d1e69..b4c9d348c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/Loop.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/Loop.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -358,8 +358,8 @@ public class Loop extends AuditEntity implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}