aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-09-12 10:28:35 -0400
committerPamela Dragosh <pdragosh@research.att.com>2017-09-12 12:46:46 -0400
commit65dff31a2e34b14347f1c0311420463c367afd3d (patch)
treebbd5dba3e1f48449c43085ef373e6ca235760bbc /integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
parent5827bc8c28d85f536ac2dff3c4e03ab83f0f8408 (diff)
Fix sonar critical associated with logging
Addressing the following sonar critical: Use a logger to log this exception Either log or rethrow this exception It does not hurt to simply do these as well as clean out lines of code that dump to Sys.out via e.printStackTrace. Issue-ID: POLICY-195 Change-Id: Ibc328094a0653b7baa04778298e4a69955105ea3 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java')
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java32
1 files changed, 16 insertions, 16 deletions
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
index ce042541..fef4b897 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
@@ -549,8 +549,8 @@ public class IntegrityMonitor {
} catch (Exception e) {
String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ "; " + e.getMessage();
- logger.debug(msg);
- logger.error(msg);
+ logger.debug(msg, e);
+ logger.error(msg, e);
}
}
}
@@ -844,6 +844,7 @@ public class IntegrityMonitor {
this.stateManager.disableDependency();
}
} catch (Exception e) {
+ logger.error(e);
if (!error_msg.isEmpty()) {
error_msg = error_msg.concat(",");
}
@@ -867,6 +868,7 @@ public class IntegrityMonitor {
this.stateManager.enableNoDependency();
} // The refreshStateAudit will catch the case where it is disabled but availStatus != failed
} catch (Exception e) {
+ logger.error(e);
if (!error_msg.isEmpty()) {
error_msg = error_msg.concat(",");
}
@@ -887,6 +889,7 @@ public class IntegrityMonitor {
this.stateManager.enableNoDependency();
}// The refreshStateAudit will catch the case where it is disabled but availStatus != failed
} catch (Exception e) {
+ logger.error(e);
if (!error_msg.isEmpty()) {
error_msg = error_msg.concat(",");
}
@@ -913,6 +916,7 @@ public class IntegrityMonitor {
error_msg = error_msg.concat(resourceName + ": " + e.getMessage());
this.stateManager.disableDependency();
} catch (Exception ex) {
+ logger.error(ex);
if (!error_msg.isEmpty()) {
error_msg = error_msg.concat(",");
}
@@ -943,7 +947,7 @@ public class IntegrityMonitor {
try {
startTransaction();
} catch (AdministrativeStateException | StandbyStatusException e) {
- // ignore
+ logger.debug(e);
}
// TODO: add test functionality if needed
@@ -1049,7 +1053,7 @@ public class IntegrityMonitor {
}
}
} catch (Exception e1) {
- // ignore
+ logger.debug(e1);
}
logger.error("writeFpc DB table commit failed with exception: " + e);
throw e;
@@ -1131,7 +1135,7 @@ public class IntegrityMonitor {
dep_groups = prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS).split(";");
logger.info("dependency groups property = " + Arrays.toString(dep_groups));
} catch (Exception e) {
- logger.warn("Ignored invalid property: " + IntegrityMonitorProperties.DEPENDENCY_GROUPS);
+ logger.warn("Ignored invalid property: " + IntegrityMonitorProperties.DEPENDENCY_GROUPS, e);
}
}
@@ -1203,7 +1207,7 @@ public class IntegrityMonitor {
try {
validateProperties(newprop);
} catch (IntegrityMonitorPropertiesException e) {
- // ignore
+ logger.debug(e);
}
}
else {
@@ -1355,9 +1359,9 @@ public class IntegrityMonitor {
}
} catch (Exception e) {
// log an error
- String msg = "IntegrityMonitor.stateAudit(): " + fpe.getResourceName() + ": StateManagementEntity DB read failed with exception: " + e;
+ String msg = "IntegrityMonitor.stateAudit(): " + fpe.getResourceName() + ": StateManagementEntity DB read failed with exception: ";
+ logger.error(msg, e);
logger.debug(msg);
- logger.error(msg);
synchronized(IMFLUSHLOCK){
if(et.isActive()){
et.rollback();
@@ -1372,7 +1376,7 @@ public class IntegrityMonitor {
} catch (Exception e) {
String msg = "IntegrityMonitor.stateAudit(): Failed to disable " + sme.getResourceName();
logger.debug(msg);
- logger.error(msg);
+ logger.error(msg, e);
}
}
}// end if(diffMs > staleMs)
@@ -1427,7 +1431,7 @@ public class IntegrityMonitor {
try {
writeFpc();
} catch (Exception e) {
- // ignore
+ logger.debug(e);
}
}
}
@@ -1477,9 +1481,6 @@ public class IntegrityMonitor {
stateManager.lock();
} catch (Exception e) {
logger.error("refreshStateAudit: caught unexpected exception from stateManager.lock(): " + e );
- System.out.println(new Date() + " refreshStateAudit: caught unexpected exception "
- + "from stateManager.lock()");
- e.printStackTrace();
}
}else{//unlocked
try {
@@ -1487,9 +1488,6 @@ public class IntegrityMonitor {
stateManager.unlock();;
} catch (Exception e) {
logger.error("refreshStateAudit: caught unexpected exception from stateManager.unlock(): " + e );
- System.out.println(new Date() + " refreshStateAudit: caught unexpected exception "
- + "from stateManager.unlock()");
- e.printStackTrace();
}
}
refreshStateAuditLastRunDate = new Date();
@@ -1528,6 +1526,8 @@ public class IntegrityMonitor {
Thread.sleep(CYCLE_INTERVAL_MILLIS);
} catch (InterruptedException e) {
// The 'sleep' call was interrupted
+ logger.debug(e);
+ Thread.currentThread().interrupt();
continue;
}