From f4895ff98b3ed83b44733adc20ad8cf0092a3d83 Mon Sep 17 00:00:00 2001 From: "puthuparambil.aditya" Date: Thu, 6 Aug 2020 13:03:38 +0100 Subject: Handling apex-pdp multi policy deployment failure: 1.Include the list of duplicate parameters in the logs for easier troubleshooting 2.Also fix 4 Sonar blockers in ApexMainTest.java Issue-ID: POLICY-2712 Signed-off-by: puthuparambil.aditya Change-Id: I145a7e03f76f880f8e3cbde97284748468b354a5 --- .../policy/apex/service/engine/main/ApexActivator.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'services/services-engine/src/main/java') diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java index 1e2447b2e..a928f208c 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java @@ -24,6 +24,7 @@ package org.onap.policy.apex.service.engine.main; import java.io.IOException; import java.util.AbstractMap; +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -133,16 +134,19 @@ public class ApexActivator { new LinkedHashSet<>(apexParametersMap.entrySet()); apexParamsEntrySet.stream().forEach(apexParamsEntry -> { ApexParameters apexParams = apexParamsEntry.getValue(); - boolean duplicateInputParameterExist = - apexParams.getEventInputParameters().keySet().stream().anyMatch(inputParametersMap::containsKey); - boolean duplicateOutputParameterExist = - apexParams.getEventOutputParameters().keySet().stream().anyMatch(outputParametersMap::containsKey); - if (duplicateInputParameterExist || duplicateOutputParameterExist) { - LOGGER.error("I/O Parameters for {}:{} has duplicates. So this policy is not executed.", - apexParamsEntry.getKey().getName(), apexParamsEntry.getKey().getVersion()); + List duplicateInputParameters = new ArrayList<>(apexParams.getEventInputParameters().keySet()); + duplicateInputParameters.retainAll(inputParametersMap.keySet()); + List duplicateOutputParameters = new ArrayList<>(apexParams.getEventOutputParameters().keySet()); + duplicateOutputParameters.retainAll(outputParametersMap.keySet()); + + if (!(duplicateInputParameters.isEmpty() && duplicateOutputParameters.isEmpty())) { + LOGGER.error("I/O Parameters {}/{} for {}:{} are duplicates. So this policy is not executed.", + duplicateInputParameters, duplicateOutputParameters, apexParamsEntry.getKey().getName(), + apexParamsEntry.getKey().getVersion()); apexParametersMap.remove(apexParamsEntry.getKey()); return; } + inputParametersMap.putAll(apexParams.getEventInputParameters()); outputParametersMap.putAll(apexParams.getEventOutputParameters()); // Check if a policy model file has been specified -- cgit 1.2.3-korg