From: shashikanth Date: Tue, 19 Sep 2017 09:27:58 +0000 (+0530) Subject: Fix Blocker/Critical sonar issues X-Git-Tag: v1.1.0~64^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F13377%2F2;p=policy%2Fdrools-applications.git Fix Blocker/Critical sonar issues Fix Blocker/Critical sonar issues in policy/drools-applications module https://sonar.onap.org/component_issues?id=org.onap.policy.drools-applications%3Adrools-pdp-apps#resolved=false|severities=CRITICAL%2CMAJOR Fixed 2 issues, Used isEmpty() to check whether the collection is empty or not. getActor returns a string, there's no need to call toString() Issue-Id:POLICY-111 Change-Id: I645420ee370ceb5fca959f870e76db2390e19929 Signed-off-by: shashikanth.vh --- diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 8849a2351..a772efce3 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -189,7 +189,7 @@ public class ControlLoopOperationManager implements Serializable { this.policyResult = null; Operation operation = new Operation(); operation.attempt = ++this.attempts; - operation.operation.actor = this.policy.getActor().toString(); + operation.operation.actor = this.policy.getActor(); operation.operation.operation = this.policy.getRecipe(); operation.operation.target = this.policy.getTarget().toString(); operation.operation.subRequestId = Integer.toString(operation.attempt); @@ -400,7 +400,8 @@ public class ControlLoopOperationManager implements Serializable { if (this.currentOperation != null && this.currentOperation.operation != null) { return this.currentOperation.operation.toMessage(); } - if (this.operationHistory != null && this.operationHistory.size() > 0) { + + if (!this.operationHistory.isEmpty()) { return this.operationHistory.getLast().operation.toMessage(); } return null; @@ -410,7 +411,8 @@ public class ControlLoopOperationManager implements Serializable { if (this.currentOperation != null && this.currentOperation.operation != null) { return this.currentOperation.operation.toMessage()+ ", Guard result: " + guardResult; } - if (this.operationHistory != null && this.operationHistory.size() > 0) { + + if (!this.operationHistory.isEmpty()) { return this.operationHistory.getLast().operation.toMessage() + ", Guard result: " + guardResult; } return null; @@ -420,7 +422,8 @@ public class ControlLoopOperationManager implements Serializable { if (this.currentOperation != null && this.currentOperation.operation != null) { return this.currentOperation.operation.toHistory(); } - if (this.operationHistory != null && this.operationHistory.size() > 0) { + + if (!this.operationHistory.isEmpty()) { return this.operationHistory.getLast().operation.toHistory(); } return null; diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java index 484e793e2..85427c468 100644 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java +++ b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LCMResponseCode.java @@ -41,6 +41,7 @@ public class LCMResponseCode { return this.code; } + @Override public String toString() { return Integer.toString(this.code); }