Fix New Sonar Blocker for Drools-Applications 85/9185/1
authorMike Babinski <mb1915@att.com>
Tue, 29 Aug 2017 18:05:39 +0000 (18:05 +0000)
committerMike Babinski <mb1915@att.com>
Tue, 29 Aug 2017 18:07:34 +0000 (18:07 +0000)
Add null checks to stop possible null pointer exceptions.

Issue-ID: POLICY-111
Change-Id: Idafb078edf984712e5d5a4d54763f2723e17c09f
Signed-off-by: Mike Babinski <mb1915@att.com>
controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java

index 0aade07..6777353 100644 (file)
@@ -96,8 +96,13 @@ public final class VFCManager implements Runnable {
                     }
                     Thread.sleep(20000);
                 }
-                if (attemptsLeft <= 0)
-                    logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
+                if  ((attemptsLeft <= 0)
+                  && (responseGet != null)
+                  && (responseGet.responseDescriptor != null)
+                  && (responseGet.responseDescriptor.status != null) 
+                  && (!responseGet.responseDescriptor.status.isEmpty())) {     
+                        logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
+                }       
             } catch (JsonSyntaxException e) {
                 logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
             } catch (InterruptedException e) {