Added null checks for bp to prevent exceptions at 63/96263/3
authorOleksandr Moliavko <o.moliavko@samsung.com>
Thu, 26 Sep 2019 06:21:39 +0000 (09:21 +0300)
committerOleksandr Moliavko <o.moliavko@samsung.com>
Fri, 4 Oct 2019 14:25:03 +0000 (17:25 +0300)
bp.getId() calls; fixed omissions in methods
control logic; removed unneeded catch blocks

Issue-ID: SO-1841
Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com>
Change-Id: I8347b953381ebb4a112a22fc8c58a9a32f2dbfb7

adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java

index 2a17656..f1c42bb 100644 (file)
@@ -751,16 +751,19 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
         GetBlueprint getRequest = cloudify.blueprints().getMetadataById(blueprintId);
         try {
             Blueprint bp = getRequest.execute();
-            logger.debug("Blueprint exists: {}", bp.getId());
-            return true;
+            if (bp != null) {
+                logger.debug("Blueprint exists: {}", bp.getId());
+                return true;
+            } else {
+                logger.debug("Null blueprint!");
+                return false;
+            }
         } catch (CloudifyResponseException ce) {
             if (ce.getStatus() == 404) {
                 return false;
             } else {
                 throw ce;
             }
-        } catch (Exception e) {
-            throw e;
         }
     }
 
@@ -799,8 +802,12 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
         GetBlueprint getRequest = cloudify.blueprints().getMetadataById(blueprintId);
         try {
             Blueprint bp = getRequest.execute();
-            logger.debug("Blueprint {} already exists.", bp.getId());
-            return false;
+            if (bp != null) {
+                logger.debug("Blueprint {} already exists.", bp.getId());
+                return false;
+            } else {
+                logger.debug("Null blueprint!");
+            }
         } catch (CloudifyResponseException ce) {
             if (ce.getStatus() == 404) {
                 // This is the expected result.
@@ -808,8 +815,6 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
             } else {
                 throw ce;
             }
-        } catch (Exception e) {
-            throw e;
         }
 
         // Create a blueprint ZIP file in memory