Fix Sonar Blockers for Drools-Applications 97/9597/1
authorMike Babinski <mb1915@att.com>
Thu, 31 Aug 2017 05:15:13 +0000 (05:15 +0000)
committerMike Babinski <mb1915@att.com>
Thu, 31 Aug 2017 05:17:59 +0000 (05:17 +0000)
Issue-ID: POLICY-111

Add null check for pipResponse right before null check of pipResponse.gitAttributes().
Change-Id: Iba52791da1aae6900ab4dd4bb6286c3ac00e00a4
Signed-off-by: Mike Babinski <mb1915@att.com>
controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java

index 9e8ed9d..9382203 100644 (file)
@@ -185,21 +185,19 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
 
                try {
                        pipResponse     = pipFinder.getMatchingAttributes(pipRequest, this);
-                       if (pipResponse != null) {
-                               if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
+                       if  ((pipResponse != null)
+                         && (pipResponse.getStatus() != null) 
+                         && (!pipResponse.getStatus().isOk())) {
                                        logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
                                        pipResponse     = null;
-                               }
-                               if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+                       }
+                       if  ((pipResponse != null)
+                         && (pipResponse.getAttributes() != null)
+                         && (pipResponse.getAttributes().isEmpty())) {
                                        logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
                                        logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
                                        pipResponse     = null;
                                }
-                               if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
-                                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
-                                       pipResponse     = null;
-                               }
-                       }
                } catch (PIPException ex) {
                        logger.error("getAttribute threw:", ex);
                }