From 7b4bca3cb2f1c21cb2a927305bafea261cdf0769 Mon Sep 17 00:00:00 2001 From: Oleksandr Moliavko Date: Fri, 13 Sep 2019 14:51:09 +0300 Subject: Added null check to server.getImage() to prevent crash at getId() call. Issue-ID: SO-1841 Signed-off-by: Oleksandr Moliavko Change-Id: I6ecaf66649e9df971003268b7272f677c5394083 --- .../main/java/org/onap/so/heatbridge/helpers/AaiHelper.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main') diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 137aaa9f41..d8a876016f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -84,11 +84,13 @@ public class AaiHelper { relationships.add(vfModuleRelationship); // vserver to image relationship - Relationship imageRel = buildRelationship(HeatBridgeConstants.AAI_IMAGE, - ImmutableMap.builder().put(HeatBridgeConstants.AAI_CLOUD_OWNER, cloudOwner) - .put(HeatBridgeConstants.AAI_CLOUD_REGION_ID, cloudRegionId) - .put(HeatBridgeConstants.AAI_IMAGE_ID, server.getImage().getId()).build()); - relationships.add(imageRel); + if (server.getImage() != null) { + Relationship imageRel = buildRelationship(HeatBridgeConstants.AAI_IMAGE, + ImmutableMap.builder().put(HeatBridgeConstants.AAI_CLOUD_OWNER, cloudOwner) + .put(HeatBridgeConstants.AAI_CLOUD_REGION_ID, cloudRegionId) + .put(HeatBridgeConstants.AAI_IMAGE_ID, server.getImage().getId()).build()); + relationships.add(imageRel); + } // vserver to flavor relationship Relationship flavorRel = buildRelationship(HeatBridgeConstants.AAI_FLAVOR, -- cgit 1.2.3-korg