From 5c205833e4b2e8f6cfe938641cdbceaf680da92b Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 20 Mar 2018 17:28:29 +0000 Subject: Fix bugs identified by Sonar on drools-pdp Three bugs fixed: 1. Set of static variable in DMaaPSimulatorJaxR 2. Use of opssibly null variable "output" in RepositoryAudit 3. Unreachable statement error in RepositoryAudit Change-Id: I72e028cfc51a82250afd02fb4109d3dea08072dc Issue-ID: POLICY-691 Signed-off-by: liamfallon --- .../org/onap/policy/drools/statemanagement/RepositoryAudit.java | 2 +- .../policy/drools/statemanagement/StateManagementFeature.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'feature-state-management') diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java index 11134443..6ddf0c78 100644 --- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java +++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java @@ -330,7 +330,7 @@ public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase * Note: at present, this step just generates log messages, * but doesn't do any verification. */ - if (rval == 0) + if (rval == 0 && output != null) { // place output in 'fileContents' (replacing the Return characters // with Newline) diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java index 3cc27907..cb1700e4 100644 --- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java +++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java @@ -84,12 +84,13 @@ public class StateManagementFeature implements StateManagementFeatureAPI, droolsPdpIntegrityMonitor = DroolsPDPIntegrityMonitor.getInstance(); stateManagement = droolsPdpIntegrityMonitor.getStateManager(); - logger.debug("StateManagementFeature.globalInit(): " - + "stateManagement.getAdminState(): {}", stateManagement.getAdminState()); - - if(stateManagement == null){ + if (stateManagement == null) { logger.debug("StateManagementFeature.globalInit(): stateManagement is NULL!"); } + else { + logger.debug("StateManagementFeature.globalInit(): " + + "stateManagement.getAdminState(): {}", stateManagement.getAdminState()); + } } catch (Exception e1) { logger.debug("StateManagementFeature.globalInit(): DroolsPDPIntegrityMonitor" + " initialization failed with exception:", e1); -- cgit 1.2.3-korg