Null check for ClientResponse in PolicyUril.java 31/26431/1
authorHavaldar Girish <hg0071052@techmahindra.com>
Mon, 18 Dec 2017 05:42:25 +0000 (11:12 +0530)
committerHavaldar Girish <hg0071052@techmahindra.com>
Mon, 18 Dec 2017 05:50:25 +0000 (11:20 +0530)
NullPointerException might be thrown as cres is nullable here
Sonar Link:
https://sonar.onap.org/component_issues/index?id=org.onap.portal%3Aonap-portal-parent#resolved=false|severities=BLOCKER
Location:
/src/main/java/org/openecomp/portalapp/portal/scheduler/policy/PolicyUtil.java
Line No-72

Change-Id: I14dc792fb67198ebcbabfe80d90c48389af6cc91
Issue-ID: PORTAL-153
Signed-off-by: Havaldar Girish <hg0071052@techmahindra.com>
ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/scheduler/policy/PolicyUtil.java

index aa4216b..3e1c941 100644 (file)
@@ -66,10 +66,13 @@ public class PolicyUtil {
        
        public static PolicyResponseWrapper wrapResponse (ClientResponse cres) {        
                String resp_str = "";
+               int statuscode = 0;
                if ( cres != null ) {
                        resp_str = cres.readEntity(String.class);
+                       statuscode = cres.getStatus();
                }
-               int statuscode = cres.getStatus();
+               
+               
                PolicyResponseWrapper w = PolicyUtil.wrapResponse ( resp_str, statuscode );
                return (w);
        }