Potential Null pointer exception avoided 62/82962/2
authorJegadeesh Babu <jegabab1@in.ibm.com>
Thu, 21 Mar 2019 16:48:49 +0000 (22:18 +0530)
committerTakamune Cho <takamune.cho@att.com>
Fri, 22 Mar 2019 19:06:29 +0000 (19:06 +0000)
Sonar fix

Issue-ID: APPC-1552
Change-Id: I8f5e6386bd96a136f49ba651aed8fb209bed9435
Signed-off-by: Jegadeesh Babu <jegabab1@in.ibm.com>
appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebootServer.java

index 363f614..e5d73aa 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (C) 2017 Amdocs
  * ================================================================================
  * Modifications Copyright (C) 2019 Ericsson
+ * Modifications Copyright (C) 2019 IBM
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -79,6 +80,7 @@ public class RebootServer extends ProviderServerOperation {
             rebooType = "SOFT";
         }
         logger.info("reboot type" + rebooType);
+        if (ctx != null) {
         try {
             VMURL vm = VMURL.parseURL(vmUrl);
             Context context;
@@ -122,8 +124,6 @@ public class RebootServer extends ProviderServerOperation {
             }
 
         } catch (ResourceNotFoundException | StateException ex) {
-            String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, ex, ex.getClass().getSimpleName(),
-                    REBOOT_SERVICE.toString(), vmUrl, tenantName);
             ctx.setAttribute("REBOOT_STATUS", "FAILURE");
             if (ex instanceof ResourceNotFoundException) {
                 doFailure(requestContext, HttpStatus.NOT_FOUND_404, ex.getMessage());
@@ -131,11 +131,10 @@ public class RebootServer extends ProviderServerOperation {
                 doFailure(requestContext, HttpStatus.CONFLICT_409, ex.getMessage());
             }
         } catch (Exception ex) {
-            String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, ex, ex.getClass().getSimpleName(),
-                    REBOOT_SERVICE.toString(), vmUrl, tenantName);
             ctx.setAttribute("REBOOT_STATUS", "FAILURE");
             doFailure(requestContext, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.getMessage());
         }
+        }
         return server;
     }