summaryrefslogtreecommitdiffstats
path: root/integrity-audit/src/main/java
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-04 12:51:14 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-04 12:52:38 -0500
commit66221823c8cb131b8cea03c4d011ddd728608451 (patch)
tree78576114739d849c75c90dc7b2b52c9429162a29 /integrity-audit/src/main/java
parent09ca5f00b5fb88d35987e1922c34cae8469ed79d (diff)
[POLICY-96] Resolved sonar blockers in im/ia.
Resolved 7 sonar blockers in the integrity monitor and integrity audit projects. Change-Id: I7bba7619d3b71f7aebcc2642d07a64876ee7aea0 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'integrity-audit/src/main/java')
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java52
1 files changed, 38 insertions, 14 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
index 64c01931..0db43bbc 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
@@ -709,21 +709,45 @@ public class DbDAO {
* two or three milliseconds)
*/
} catch (LockTimeoutException e) {
- em.getTransaction().rollback();
- String msg = "DbDAO: " + "changeDesignated() "
- + "caught LockTimeoutException, message=" + e.getMessage();
- logger.error(msg + e);
- System.out.println(new Date());
- e.printStackTrace();
- throw new DbDaoTransactionException(msg, e);
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage();
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
+ else {
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage()
+ + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
} catch (Exception e) {
- em.getTransaction().rollback();
- 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);
+ if (em != null) {
+ em.getTransaction().rollback();
+
+ 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 {
+ String msg = "DbDAO: " + "changeDesignated() "
+ + "caught LockTimeoutException, message=" + e.getMessage()
+ + ". Error rolling back transaction.";
+ logger.error(msg + e);
+ System.out.println(new Date());
+ e.printStackTrace();
+ throw new DbDaoTransactionException(msg, e);
+ }
}
} // end synchronized block