Logging exceptions to clear sonar critical 69/12469/1
authorPamela Dragosh <pdragosh@research.att.com>
Thu, 14 Sep 2017 15:25:42 +0000 (11:25 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Thu, 14 Sep 2017 15:29:49 +0000 (11:29 -0400)
Just logging the exceptions anyway and remove e.printstack since
that goes to stdout/stderr.

Issue-ID: POLICY-195
Change-Id: I60616bd6ce633e2fcae266bb37eb735c6e6bb4c4
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java

index b392b55..e141209 100644 (file)
@@ -237,9 +237,7 @@ public class DbDAO {
                        }
                }catch(Exception e){
                        String msg = "getAllEntries encountered exception: " + e;
-                       logger.error(msg);
-                       System.out.println(new Date());
-                       e.printStackTrace();
+                       logger.error(msg, e);
                }
                em.close();
                logger.debug("getAllEntries: Exit, resultMap, size=" + resultMap.size());
@@ -331,8 +329,6 @@ public class DbDAO {
                }catch (Exception e){
                        String msg = "DbDAO: " + "setLastUpdated() " + "ecountered a problem in execution: ";
                        logger.error(msg + e);
-                       System.out.println(new Date());
-                       e.printStackTrace();
                        throw new DbDaoTransactionException(e);
                }       
        }
@@ -362,8 +358,6 @@ public class DbDAO {
                }catch (Exception e){
                        String msg = "DbDAO: " + "getIntegrityAuditEntity() " + "ecountered a problem in execution: ";
                        logger.error(msg + e);
-                       System.out.println(new Date());
-                       e.printStackTrace();
                        throw new DbDaoTransactionException(e);
                }
        }
@@ -711,8 +705,6 @@ public class DbDAO {
                                        String msg = "DbDAO: " + "changeDesignated() "
                                                        + "caught Exception, message=" + e.getMessage();
                                        logger.error(msg + e);
-                                       System.out.println(new Date());
-                                       e.printStackTrace();
                                        throw new DbDaoTransactionException(msg, e);
                                }
                                else {
index fef4b89..9d43793 100644 (file)
@@ -348,7 +348,7 @@ public class IntegrityMonitor {
                try {
                        new ComponentAdmin(resourceName, this, stateManager);
                } catch (Exception e) {
-                       logger.error("ComponentAdmin constructor exception: " + e.toString());
+                       logger.error("ComponentAdmin constructor exception: " + e);
                }
                
                new FPManager();
@@ -906,6 +906,7 @@ public class IntegrityMonitor {
                                //Test any subsystems that are not covered under the dependency relationship
                                subsystemTest();
                        }catch (Exception e){
+                               logger.error(e);
                                //This indicates a subsystemTest failure
                                try {
                                        logger.info(resourceName + ": There has been a subsystemTest failure with error: " + e.getMessage() + "  Updating this resource's state to disableDependency");