diff options
author | k.kazak <k.kazak@samsung.com> | 2019-06-10 09:21:44 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-06-19 07:13:33 +0000 |
commit | 2a74ec311f9fc3b430a3d768195156c7b20c5e93 (patch) | |
tree | 52b144d3b302da8592ac0edc6ac60b51936822a6 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main | |
parent | a67f45c2ab3ec438061d2bd066c8daa41b81d5bc (diff) |
fix sonar null pointer
NoveServerNamingConventionGuideLineValidator: potential null pointer fixed
Test for this use-case added
Change-Id: I3180bc6c159d1b690f0be0370abbd1fefe70045f
Issue-ID: SO-1811
Signed-off-by: k.kazak <k.kazak@samsung.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main')
1 files changed, 6 insertions, 2 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java index b2c25c2d5f..4f640dff29 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java @@ -154,6 +154,9 @@ public class NovaServerNamingConventionGuideLineValidator implements ResourceVal Map<String, String> uniqueResourcePortNetworkRole, HeatOrchestrationTemplate heatOrchestrationTemplate, GlobalValidationContext globalValidationContext) { + if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources().get(resourceId).getProperties())) { + return; + } Object propertyNetworkValue = heatOrchestrationTemplate.getResources().get(resourceId).getProperties().get("networks"); if (propertyNetworkValue != null && propertyNetworkValue instanceof List) { @@ -320,15 +323,16 @@ public class NovaServerNamingConventionGuideLineValidator implements ResourceVal private Map<String, String> validateImageAndFlavorFromNovaServer(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { + Map<String, String> imageAndFlavorLegalNames = new HashMap<>(); + if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { - return null; + return imageAndFlavorLegalNames; } Pair<String, String> imagePair = new ImmutablePair<>("image", ".*_image_name"); Pair<String, String> flavorPair = new ImmutablePair<>("flavor", ".*_flavor_name"); List<Pair<String, String>> imageFlavorPairs = Arrays.asList(imagePair, flavorPair); Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties(); - Map<String, String> imageAndFlavorLegalNames = new HashMap<>(); for (Pair<String, String> imageOrFlavor : imageFlavorPairs) { boolean isErrorInImageOrFlavor = |