From d03507850e293674cc118f76bab0629d457179ae Mon Sep 17 00:00:00 2001 From: Mike Babinski Date: Fri, 25 Aug 2017 20:56:10 +0000 Subject: Fix Sonar Blocker for Drools-Applications Add only the null check for pipResponse. Issue-ID: POLICY-111 Change-Id: I2721c759f27264ce164110a19ea8c649b74869df Signed-off-by: Mike Babinski --- .../org/onap/policy/guard/PIPEngineGetHistory.java | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'controlloop/common/guard/src') diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java index 30f1ef820..67ac170db 100644 --- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java +++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java @@ -126,13 +126,16 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ */ String string; if ((string = pipRequest.getIssuer()) == null) { + logger.debug("No issuer in the request..."); + logger.debug("FeqLimiter PIP - No issuer in the request!"); return StdPIPResponse.PIP_RESPONSE_EMPTY; } else{ //Notice, we are checking here for the base issuer prefix. if (!string.contains(this.getIssuer())) { - logger.debug("Requested issuer '" + string + "' does not match " + (this.getIssuer() == null ? "null" : "'" + this.getIssuer() + "'")); + logger.debug("Requested issuer '{}' does not match {}", string, (this.getIssuer() == null ? "null" : "'" + this.getIssuer() + "'")); + logger.debug("FeqLimiter PIP - Issuer {} does not match with: ", string, this.getIssuer()); return StdPIPResponse.PIP_RESPONSE_EMPTY; } } @@ -148,7 +151,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ String timeWindow = timeWindowVal + " " + timeWindowScale; - logger.debug("Going to query DB about: "+actor + " " + operation + " " + target + " " + timeWindow); + logger.debug("Going to query DB about: {} {} {} {}", actor, operation, target, timeWindow); int countFromDB = getCountFromDB(actor, operation, target, timeWindow); StdMutablePIPResponse stdPIPResponse = new StdMutablePIPResponse(); @@ -182,16 +185,18 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ try { pipResponse = pipFinder.getMatchingAttributes(pipRequest, this); - if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) { - logger.debug("Error retrieving " + pipRequest.getAttributeId().stringValue() + ": " + pipResponse.getStatus().toString()); - pipResponse = null; - } - if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) { - logger.debug("No value for {}", pipRequest.getAttributeId().stringValue()); - pipResponse = null; + if (pipResponse != null) { + if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) { + logger.debug("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString()); + pipResponse = null; + } + if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) { + logger.debug("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString()); + pipResponse = null; + } } } catch (PIPException ex) { - logger.error("getAttribute threw: ", ex); + logger.error("getAttribute threw:", ex); } return pipResponse; } @@ -316,7 +321,6 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ return -1; } - em.close(); return ret; @@ -324,4 +328,4 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{ } -} +} \ No newline at end of file -- cgit 1.2.3-korg