aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2018-08-16 10:49:35 +0300
committertalio <tali.orenbach@amdocs.com>2018-08-16 10:49:35 +0300
commitfc752e96f324f9027a20e1b071167bf294202545 (patch)
tree133b983d169df3120c1dd9e2dd6c61903860c21f /openecomp-be/lib
parent18826f28665a36830311ff480b0cc6aff561f59f (diff)
Fix NPE
Fix NPE in CompositionDataExtractor, by checking if a list is null before looping on it. Change-Id: I6441662684ad55d275626c8c813cb910ef5c00f7 Issue-ID: SDC-1513 Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java29
1 files changed, 18 insertions, 11 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
index 33ad16c12d..aded0dfbae 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
@@ -330,24 +330,31 @@ public class CompositionDataExtractorImpl implements CompositionDataExtractor {
List<String> images = imageList.get(computeId);
List<String> computeFlavors = computeFlavorNodeTemplates.get(computeId);
- if (connectedPortIds != null) {
+ if (CollectionUtils.isNotEmpty(connectedPortIds)) {
componentModel.setNics(new ArrayList<>());
componentModel.setImages(new ArrayList<>());
componentModel.setCompute(new ArrayList<>());
- for (String portId : connectedPortIds) {
+
+ connectedPortIds.forEach(portId -> {
Nic port = extractPort(serviceTemplate, portId);
componentModel.getNics().add(port);
context.addNic(portId, port);
+ });
+
+ if (CollectionUtils.isNotEmpty(images)) {
+ images.forEach(image -> {
+ Image img = new Image(image);
+ componentModel.getImages().add(img);
+ context.addImage(image, img);
+ });
}
- for (String image : images) {
- Image img = new Image(image);
- componentModel.getImages().add(img);
- context.addImage(image, img);
- }
- for (String flavor : computeFlavors) {
- ComputeData computeFlavor = new ComputeData(flavor);
- componentModel.getCompute().add(computeFlavor);
- context.addCompute(flavor,computeFlavor);
+
+ if (CollectionUtils.isNotEmpty(computeFlavors)) {
+ computeFlavors.forEach(flavor -> {
+ ComputeData computeFlavor = new ComputeData(flavor);
+ componentModel.getCompute().add(computeFlavor);
+ context.addCompute(flavor, computeFlavor);
+ });
}
}
context.addComponent(componentModel);